16 Library introduction [library]

16.5 Library-wide requirements [requirements]

16.5.3 Requirements on types and expressions [utility.requirements]

16.5.3.4 Cpp17Hash requirements [hash.requirements]

A type H meets the Cpp17Hash requirements if:
  • it is a function object type ([function.objects]),
  • it meets the Cpp17CopyConstructible (Table 29) and Cpp17Destructible (Table 32) requirements, and
  • the expressions shown in Table 34 are valid and have the indicated semantics.
Given Key is an argument type for function objects of type H, in Table 34 h is a value of type (possibly const) H, u is an lvalue of type Key, and k is a value of a type convertible to (possibly const) Key.
Table 34: Cpp17Hash requirements   [tab:cpp17.hash]
Expression
Return type
Requirement
h(k)
size_­t
The value returned shall depend only on the argument k for the duration of the program.
[Note
:
Thus all evaluations of the expression h(k) with the same value for k yield the same result for a given execution of the program.
— end note
]
[Note
:
For two different values t1 and t2, the probability that h(t1) and h(t2) compare equal should be very small, approaching 1.0 / numeric_­limits<size_­t>​::​max().
— end note
]
h(u)
size_­t
Shall not modify u.