43 lines
2.7 KiB
Markdown
43 lines
2.7 KiB
Markdown
[hash.requirements]
|
||
|
||
# 16 Library introduction [[library]](./#library)
|
||
|
||
## 16.4 Library-wide requirements [[requirements]](requirements#hash.requirements)
|
||
|
||
### 16.4.4 Requirements on types and expressions [[utility.requirements]](utility.requirements#hash.requirements)
|
||
|
||
#### 16.4.4.5 *Cpp17Hash* requirements [hash.requirements]
|
||
|
||
[1](#1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2096)
|
||
|
||
A type H meets the *Cpp17Hash* requirements if
|
||
|
||
- [(1.1)](#1.1)
|
||
|
||
it is a function object type ([[function.objects]](function.objects "22.10 Function objects")),
|
||
|
||
- [(1.2)](#1.2)
|
||
|
||
it meets the [*Cpp17CopyConstructible*](utility.arg.requirements#:Cpp17CopyConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") (Table [32](utility.arg.requirements#tab:cpp17.copyconstructible "Table 32: Cpp17CopyConstructible requirements (in addition to Cpp17MoveConstructible)")) and [*Cpp17Destructible*](utility.arg.requirements#:Cpp17Destructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") (Table [35](utility.arg.requirements#tab:cpp17.destructible "Table 35: Cpp17Destructible requirements")) requirements, and
|
||
|
||
- [(1.3)](#1.3)
|
||
|
||
the expressions shown in Table [37](#tab:cpp17.hash "Table 37: Cpp17Hash requirements") are valid and have the indicated semantics[.](#1.sentence-1)
|
||
|
||
[2](#2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2106)
|
||
|
||
Given Key is an argument type for function objects of type H, in
|
||
Table [37](#tab:cpp17.hash "Table 37: Cpp17Hash requirements") 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[.](#2.sentence-1)
|
||
|
||
Table [37](#tab:cpp17.hash) — *Cpp17Hash* requirements [[tab:cpp17.hash]](./tab:cpp17.hash)
|
||
|
||
| [ð](#tab:cpp17.hash-row-1)<br>**Expression** | **Return type** | **Requirement** |
|
||
| --- | --- | --- |
|
||
| [ð](#tab:cpp17.hash-row-2)<br>h(k) | size_t | The value returned shall depend only on the argument k for the duration of the program[.](#tab:cpp17.hash-row-2-column-3-sentence-1)<br>[*Note [1](#tab:cpp17.hash-row-2-column-3-note-1)*:<br>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[.](#tab:cpp17.hash-row-2-column-3-sentence-2) â *end note*]<br> 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()[.](#tab:cpp17.hash-row-2-column-3-sentence-3) |
|
||
| [ð](#tab:cpp17.hash-row-3)<br>h(u) | size_t | Shall not modify u[.](#tab:cpp17.hash-row-3-column-3-sentence-1) |
|