Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

value_compare Class (<map>)


The new home for Visual Studio documentation is Visual Studio 2017 Documentation on

The latest version of this topic can be found at value_compare Class (<map>).

Provides a function object that can compare the elements of a map by comparing the values of their keys to determine their relative order in the map.

class value_compare : public binary_function<value_type, value_type, bool>
    bool operator()(const value_type& left, const value_type& right) const;

    value_compare(key_compare pred) : comp(pred);

 key_compare comp;

The comparison criterion provided by value_compare between value_types of whole elements contained by a map is induced from a comparison between the keys of the respective elements by the auxiliary class construction. The member function operator uses the object comp of type key_compare stored in the function object provided by value_compare to compare the sort-key components of two elements.

For sets and multisets, which are simple containers where the key values are identical to the element values, value_compare is equivalent to key_compare; for maps and multimaps they are not, as the value of the type pair elements is not identical to the value of the element's key.

See example for value_comp for an example of how to declare and use value_compare.

Header: <map>

Namespace: std

binary_function Struct
Thread Safety in the C++ Standard Library
Standard Template Library

© 2017 Microsoft