tmp/tmpfjoj1kqe/{from.md → to.md}
RENAMED
|
@@ -1,48 +1,46 @@
|
|
| 1 |
### Class template `hash` <a id="unord.hash">[[unord.hash]]</a>
|
| 2 |
|
| 3 |
The unordered associative containers defined in [[unord]] use
|
| 4 |
-
specializations of the class template `hash`
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
- satisfy the `Hash` requirements ([[hash.requirements]]), with `Key`
|
| 10 |
as the function call argument type, the `DefaultConstructible`
|
| 11 |
-
requirements (Table [[defaultconstructible]]), the
|
| 12 |
-
requirements (Table [[copyassignable]]),
|
| 13 |
- be swappable ([[swappable.requirements]]) for lvalues,
|
| 14 |
-
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
is also true, where `h` is an object of type `hash<Key>` and `k1` and
|
| 18 |
-
`k2` are objects of type `Key`;
|
| 19 |
- satisfy the requirement that the expression `h(k)`, where `h` is an
|
| 20 |
object of type `hash<Key>` and `k` is an object of type `Key`, shall
|
| 21 |
not throw an exception unless `hash<Key>` is a user-defined
|
| 22 |
specialization that depends on at least one user-defined type.
|
| 23 |
|
| 24 |
-
``` cpp
|
| 25 |
-
template <> struct hash<bool>;
|
| 26 |
-
template <> struct hash<char>;
|
| 27 |
-
template <> struct hash<signed char>;
|
| 28 |
-
template <> struct hash<unsigned char>;
|
| 29 |
-
template <> struct hash<char16_t>;
|
| 30 |
-
template <> struct hash<char32_t>;
|
| 31 |
-
template <> struct hash<wchar_t>;
|
| 32 |
-
template <> struct hash<short>;
|
| 33 |
-
template <> struct hash<unsigned short>;
|
| 34 |
-
template <> struct hash<int>;
|
| 35 |
-
template <> struct hash<unsigned int>;
|
| 36 |
-
template <> struct hash<long>;
|
| 37 |
-
template <> struct hash<unsigned long>;
|
| 38 |
-
template <> struct hash<long long>;
|
| 39 |
-
template <> struct hash<unsigned long long>;
|
| 40 |
-
template <> struct hash<float>;
|
| 41 |
-
template <> struct hash<double>;
|
| 42 |
-
template <> struct hash<long double>;
|
| 43 |
-
template <class T> struct hash<T*>;
|
| 44 |
-
```
|
| 45 |
-
|
| 46 |
-
The template specializations shall meet the requirements of class
|
| 47 |
-
template `hash` ([[unord.hash]]).
|
| 48 |
-
|
|
|
|
| 1 |
### Class template `hash` <a id="unord.hash">[[unord.hash]]</a>
|
| 2 |
|
| 3 |
The unordered associative containers defined in [[unord]] use
|
| 4 |
+
specializations of the class template `hash` ([[functional.syn]]) as
|
| 5 |
+
the default hash function.
|
| 6 |
+
|
| 7 |
+
Each specialization of `hash` is either enabled or disabled, as
|
| 8 |
+
described below.
|
| 9 |
+
|
| 10 |
+
[*Note 1*: Enabled specializations meet the requirements of `Hash`, and
|
| 11 |
+
disabled specializations do not. — *end note*]
|
| 12 |
+
|
| 13 |
+
Each header that declares the template `hash` provides enabled
|
| 14 |
+
specializations of `hash` for `nullptr_t` and all cv-unqualified
|
| 15 |
+
arithmetic, enumeration, and pointer types. For any type `Key` for which
|
| 16 |
+
neither the library nor the user provides an explicit or partial
|
| 17 |
+
specialization of the class template `hash`, `hash<Key>` is disabled.
|
| 18 |
+
|
| 19 |
+
If the library provides an explicit or partial specialization of
|
| 20 |
+
`hash<Key>`, that specialization is enabled except as noted otherwise,
|
| 21 |
+
and its member functions are `noexcept` except as noted otherwise.
|
| 22 |
+
|
| 23 |
+
If `H` is a disabled specialization of `hash`, these values are `false`:
|
| 24 |
+
`is_default_constructible_v<H>`, `is_copy_constructible_v<H>`,
|
| 25 |
+
`is_move_constructible_v<H>`, `is_copy_assignable_v<H>`, and
|
| 26 |
+
`is_move_assignable_v<H>`. Disabled specializations of `hash` are not
|
| 27 |
+
function object types ([[function.objects]]).
|
| 28 |
+
|
| 29 |
+
[*Note 2*: This means that the specialization of `hash` exists, but any
|
| 30 |
+
attempts to use it as a `Hash` will be ill-formed. — *end note*]
|
| 31 |
+
|
| 32 |
+
An enabled specialization `hash<Key>` will:
|
| 33 |
|
| 34 |
- satisfy the `Hash` requirements ([[hash.requirements]]), with `Key`
|
| 35 |
as the function call argument type, the `DefaultConstructible`
|
| 36 |
+
requirements (Table [[tab:defaultconstructible]]), the
|
| 37 |
+
`CopyAssignable` requirements (Table [[tab:copyassignable]]),
|
| 38 |
- be swappable ([[swappable.requirements]]) for lvalues,
|
| 39 |
+
- satisfy the requirement that if `k1 == k2` is `true`, `h(k1) == h(k2)`
|
| 40 |
+
is also `true`, where `h` is an object of type `hash<Key>` and `k1`
|
| 41 |
+
and `k2` are objects of type `Key`;
|
|
|
|
|
|
|
| 42 |
- satisfy the requirement that the expression `h(k)`, where `h` is an
|
| 43 |
object of type `hash<Key>` and `k` is an object of type `Key`, shall
|
| 44 |
not throw an exception unless `hash<Key>` is a user-defined
|
| 45 |
specialization that depends on at least one user-defined type.
|
| 46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|