C++ Logo

std-proposals

Advanced search

[std-proposals] Introduction of value_equal

From: LoS <aurumpuro_at_[hidden]>
Date: Sat, 1 Apr 2023 18:24:06 +0200
I do not know if it has already been proposed, but it seems not.
The std::map container already provides a value_compare member class that
allows to compare two value_type objects using the key_compare comparison
object under the hood.
This allows the user to directly call an instance of the value_compare
comparison object and thus perform a compare operation between two
value_type objects easily.
However, it is not possible to do such a thing with std::unordered_map,
because it does not provide a member class that allows to compare two
value_type objects in a equivalence relation using the key_equal object
under the hood.
I propose the introduction of a value_equal member class:

MEMBER FUNCTIONS
value_equal( KeyEqual p );
(protected member function)
Initializes the internal instance of the object to p.

bool operator()( const value_type& lhs, const value_type& rhs ) const;
(public member function)
Compares lhs.first and rhs.first in a equivalence relation by calling the
stored object.

PROTECTED MEMBER OBJECT
KeyEqual equal;

Received on 2023-04-01 16:24:20