This comparison object is set on object construction, and may either be a pointer to a function or an object of a class with a function call operator. In both cases it takes two arguments of the same type as the element keys, and returns true if the first argument is considered to go before the second in the strict weak ordering for the multimap object, and false otherwise.
Notice that the returned comparison object takes as parameters the element keys themselves, not entire element values (pairs) as referenced by a multimap iterator. To compare the keys of elements using dereferenced iterators, the member function multimap::value_comp may better suit your needs.
Parameters
noneReturn value
The key comparison object.multimap::key_compare is a member type defined to Compare, which is the third template parameter in the multimap class template.
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 27 28 29 30 31 32 |
|
Output:
mymap contains: a => 100 b => 200 b => 211 c => 300 |
Complexity
Constant.See also
| multimap::value_comp | Return value comparison object (public member function) |
| multimap::find | Get iterator to element (public member function) |
| multimap::count | Count elements with a specific key (public member function) |
| multimap::lower_bound | Return iterator to lower bound (public member function) |
| multimap::upper_bound | Return iterator to upper bound (public member function) |
