The mapped value, although part of the pair, is not taken into consideration in this comparison - only the key value.
The comparison object returned is an object of the member type map::value_compare, which is a nested class that uses the Compare class from the map template class (the third template parameter) to generate the appropriate comparison class:
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
The public member of this comparison class returns true if the key of the first argument is considered to go before that of the second, according to the strict weak ordering specified by the comparison object on map construction, and false otherwise.
Notice that value_compare has no public constructor, therefore no objects can be directly created from this nested class outside map members.
Parameters
noneReturn value
The value comparison object.map::value_compare is a member type defined as described above.
Example
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
|
Output:
mymap contains: x => 1001 y => 2002 z => 3003 |
Complexity
Constant.See also
| map::key_comp | Return key comparison object (public member function) |
| map::find | Get iterator to element (public member function) |
| map::count | Count elements with a specific key (public member function) |
| map::lower_bound | Return iterator to lower bound (public member function) |
| map::upper_bound | Return iterator to upper bound (public member function) |
