Skip to content

Fix invalid std:: prefix for public keyword and update value_compare class reference #5553

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 13 additions & 14 deletions docs/standard-library/value-compare-class.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
---
description: "Learn more about: value_compare Class"
title: "value_compare Class"
ms.date: "11/04/2016"
description: "Learn more about: value_compare Class"
ms.date: 11/04/2016
f1_keywords: ["hash_map/std::value_compare"]
helpviewer_keywords: ["value_compare class"]
ms.assetid: c306c5b9-3505-4357-aa6b-216451b951ed
---
# value_compare Class
# `value_compare` Class

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

## Syntax

```cpp
class value_compare
: std::public binary_function<value_type, value_type, bool>
: public binary_function<value_type, value_type, bool>
{
public:
bool operator()(
Expand All @@ -32,22 +31,22 @@ protected:

## Remarks

The comparison criteria provided by value_compare between `value_types` of whole elements contained by a hash_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.
The comparison criteria provided by `value_compare` between `value_types` of whole elements contained by a `hash_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 hash_sets and hash_multisets, which are simple containers where the key values are identical to the element values, value_compare is equivalent to `key_compare`; for hash_maps and hash_multimaps they are not, because the value of the type `pair` elements is not identical to the value of the element's key.
For `hash_set`s and `hash_multiset`s, which are simple containers where the key values are identical to the element values, `value_compare` is equivalent to `key_compare`; for `hash_map`s and `hash_multimap`s they are not, because the value of the type `pair` elements is not identical to the value of the element's key.

## Example

See the example for [hash_map::value_comp](../standard-library/hash-map-class.md#value_comp) for an example of how to declare and use value_compare.
See the example for [`hash_map::value_comp`](hash-map-class.md#value_comp) for an example of how to declare and use `value_compare`.

## Requirements

**Header:** \<hash_map>
**Header:** `<hash_map>`

**Namespace:** stdext
**Namespace:** `stdext`

## See also

[binary_function Struct](../standard-library/binary-function-struct.md)\
[Thread Safety in the C++ Standard Library](../standard-library/thread-safety-in-the-cpp-standard-library.md)\
[C++ Standard Library Reference](../standard-library/cpp-standard-library-reference.md)
[`binary_function` Struct](binary-function-struct.md)\
[Thread Safety in the C++ Standard Library](thread-safety-in-the-cpp-standard-library.md)\
[C++ Standard Library Reference](cpp-standard-library-reference.md)