Since C ++ 14 (see 17.6.3.4 Hash Requirements, Table 26), we have:
The return value will 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 give the same result for a given execution of the program . - final note]
Two different executions can produce different hashes :
Hashing functions are necessary only to obtain the same result for the same input within the same program execution ; this allows salty hashes to prevent DoS attacks in a collision .
This behavior is useful for mitigating a hash collision based on a DoS attack .
More details
Here is the wording of the concept requirements Hashfrom the C ++ 17 standard:
k . [: , h (k) k . - ]
. std::hash .
N3242 2011-02-28 , " ":
. k. [: , h (k) k . -
, " " " " "2291. std:: hash DoS .
AFAIU, std::hash , my::secure_hash.