Skip to content

Latest commit

 

History

History
46 lines (33 loc) · 1.91 KB

value-compare-class-map.md

File metadata and controls

46 lines (33 loc) · 1.91 KB
description title ms.date f1_keywords helpviewer_keywords ms.assetid
Learn more about: value_compare Class (<map>)
value_compare Class (<map>)
11/04/2016
std::value_compare
std.value_compare
map/std::value_compare
std::value_compare
ea97c1d0-04b2-4d42-8d96-23522c04cc41

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.

Syntax

class value_compare : public binary_function<value_type, value_type, bool>
{
public:
    bool operator()(const value_type& left, const value_type& right) const;
    value_compare(key_compare pred) : comp(pred);
protected:
    key_compare comp;
};

Remarks

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.

Example

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

Requirements

Header: <map>

Namespace: std

See also

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