|
|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
AHash 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.
The typeT satisfiesHash if
T satisfiesFunctionObject,CopyConstructible,Destructible, andGiven
T orconst T, whose argument type isKey,Key orconst Key,Key.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 ofk for the duration of the program. All evaluations ofh(k) executed within a given execution of a program yield the same result for the same value ofk. The probability ofh(a)== h(b) fora!= b should approach1.0/std::numeric_limits<std::size_t>::max(). |
| h(u) | std::size_t | u is not modified. |
(C++11) | hash function object (class template)[edit] |
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
| DR | Applied to | Behavior as published | Correct behavior |
|---|---|---|---|
| LWG 2291 | C++11 | same results for same arguments were required in all cases | only required within a single execution |