C++ named requirements: Hash
From cppreference.com
A Hash is a function object for which the output depends only on the input and has a very low probability of yielding the same output given different input values.
Requirements
The type T
satisfies Hash if
- The type
T
satisfies FunctionObject, CopyConstructible, Destructible, and
Given
-
h
, a value of typeT
orconst T
, whose argument type isKey
-
k
, a value of type convertible toKey
orconst Key
-
u
, an lvalue expression of typeKey
The following expressions must be valid and have their specified effects
Expression | Return type | Requirements |
---|---|---|
h(k) | std::size_t
|
the returned value depends only on the value of k for the duration of the program (since C++14)
All evaluations of h(k) executed within a given execution of a program (since C++14) yield the same result for the same value of The probability of h(a)==h(b) for a!=b should approach 1.0/std::numeric_limits<std::size_t>::max(). |
h(u) | std::size_t
|
u is not modified
|
Standard library
std::hash |