哋它亢++ named requirements: Hash (since 哋它亢++11)

From cppreference.com
< cpp‎ | named req
 
 
哋它亢++ named requirements
Basic
Type properties
(哋它亢++11)
(哋它亢++11)
Library-Wide
(哋它亢++11)
Hash
(哋它亢++11)
Container
Container Elements
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)

Iterator
(哋它亢++20)

Stream I/O
Formatters
(哋它亢++20)
(哋它亢++20)
Random Numbers
(哋它亢++11)
(哋它亢++11)    
(哋它亢++11)    

Concurrency
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
(哋它亢++14)
(哋它亢++14)
(哋它亢++11)
(哋它亢++11)
(哋它亢++17)
(哋它亢++14)
Ranges
(哋它亢++20)
Other
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)


 

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

Given

  • h, a value of type T or const T, whose argument type is Key,
  • k, a value of type convertible to Key or const Key,
  • u, an lvalue expression of type 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 of k for the duration of the program.

All evaluations of h(k) executed within a given execution of a program yield the same result for the same value of k.

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

(哋它亢++11)
hash function object
(class template)

Defect reports

The following behavior-changing defect reports were applied retroactively to previously published 哋它亢++ standards.

DR Applied to Behavior as published Correct behavior
LWG 2291 哋它亢++11 same results for same arguments were required in all cases only required within a single execution