22 General utilities library [utilities] (original) (raw)

22.10 Function objects [function.objects]

22.10.19 Class template hash [unord.hash]

The unordered associative containers defined in [unord] use specializations of the class template hash ([functional.syn]) as the default hash function.

Each specialization of hash is either enabled or disabled, as described below.

[Note 1:

Enabled specializations meet the Cpp17Hash requirements, and disabled specializations do not.

— _end note_]

Each header that declares the template hashprovides enabled specializations of hash for nullptr_t and all cv-unqualified arithmetic, enumeration, and pointer types.

For any type Key for which neither the library nor the user provides an explicit or partial specialization of the class template hash,hash<Key> is disabled.

If the library provides an explicit or partial specialization of hash<Key>, that specialization is enabled except as noted otherwise, and its member functions are noexcept except as noted otherwise.

If H is a disabled specialization of hash, these values are false:is_default_constructible_v<H>,is_copy_constructible_v<H>,is_move_constructible_v<H>,is_copy_assignable_v<H>, andis_move_assignable_v<H>.

Disabled specializations of hashare not function object types ([function.objects]).

[Note 2:

This means that the specialization of hash exists, but any attempts to use it as a Cpp17Hash will be ill-formed.

— _end note_]

An enabled specialization hash<Key> will: