From Jason Turner

[unord.req]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp063svu91/{from.md → to.md} +67 -36
tmp/tmp063svu91/{from.md → to.md} RENAMED
@@ -25,42 +25,47 @@ the *hash function* of the container. The container’s object of type
25
  the container.
26
 
27
  Two values `k1` and `k2` of type `Key` are considered equivalent if the
28
  container’s key equality predicate returns `true` when passed those
29
  values. If `k1` and `k2` are equivalent, the container’s hash function
30
- shall return the same value for both. Thus, when an unordered
31
- associative container is instantiated with a non-default `Pred`
32
- parameter it usually needs a non-default `Hash` parameter as well. For
33
- any two keys `k1` and `k2` in the same container, calling `pred(k1, k2)`
34
- shall always return the same value. For any key `k` in a container,
35
- calling `hash(k)` shall always return the same value.
 
 
 
36
 
37
  An unordered associative container supports *unique keys* if it may
38
  contain at most one element for each key. Otherwise, it supports
39
  *equivalent keys*. `unordered_set` and `unordered_map` support unique
40
  keys. `unordered_multiset` and `unordered_multimap` support equivalent
41
  keys. In containers that support equivalent keys, elements with
42
  equivalent keys are adjacent to each other in the iteration order of the
43
  container. Thus, although the absolute order of elements in an unordered
44
  container is not specified, its elements are grouped into
45
- *equivalent-key group*s such that all elements of each group have
46
  equivalent keys. Mutating operations on unordered containers shall
47
  preserve the relative order of elements within each equivalent-key group
48
  unless otherwise specified.
49
 
50
  For `unordered_set` and `unordered_multiset` the value type is the same
51
  as the key type. For `unordered_map` and `unordered_multimap` it is
52
- `std::pair<const Key,
53
  T>`.
54
 
55
  For unordered containers where the value type is the same as the key
56
  type, both `iterator` and `const_iterator` are constant iterators. It is
57
  unspecified whether or not `iterator` and `const_iterator` are the same
58
- type. `iterator` and `const_iterator` have identical semantics in this
59
- case, and `iterator` is convertible to `const_iterator`. Users can avoid
60
- violating the One Definition Rule by always using `const_iterator` in
61
- their function parameter lists.
 
 
62
 
63
  The elements of an unordered associative container are organized into
64
  *buckets*. Keys with the same hash code appear in the same bucket. The
65
  number of buckets is automatically increased as elements are added to an
66
  unordered associative container, so that the average number of elements
@@ -73,37 +78,43 @@ the relative ordering of equivalent elements.
73
  The unordered associative containers meet all the requirements of
74
  Allocator-aware containers ([[container.requirements.general]]), except
75
  that for `unordered_map` and `unordered_multimap`, the requirements
76
  placed on `value_type` in Table 
77
  [[tab:containers.container.requirements]] apply instead to `key_type`
78
- and `mapped_type`. For example, `key_type` and `mapped_type` are
79
- sometimes required to be `CopyAssignable` even though the associated
80
- `value_type`, `pair<const key_type, mapped_type>`, is not
81
- `CopyAssignable`.
82
 
83
- In table  [[tab:HashRequirements]]: `X` is an unordered associative
84
- container class, `a` is an object of type `X`, `b` is a possibly const
85
- object of type `X`, `a_uniq` is an object of type `X` when `X` supports
86
- unique keys, `a_eq` is an object of type `X` when `X` supports
87
- equivalent keys, `i` and `j` are input iterators that refer to
88
- `value_type`, `[i, j)` is a valid range, `p` and `q2` are valid const
89
- iterators to `a`, `q` and `q1` are valid dereferenceable const iterators
90
- to `a`, `[q1, q2)` is a valid range in `a`, `il` designates an object of
91
- type `initializer_list<value_type>`, `t` is a value of type
92
- `X::value_type`, `k` is a value of type `key_type`, `hf` is a possibly
93
- const value of type `hasher`, `eq` is a possibly const value of type
94
- `key_equal`, `n` is a value of type `size_type`, and `z` is a value of
95
- type `float`.
 
 
 
 
 
 
 
 
 
96
 
97
  Two unordered containers `a` and `b` compare equal if
98
  `a.size() == b.size()` and, for every equivalent-key group \[`Ea1`,
99
  `Ea2`) obtained from `a.equal_range(Ea1)`, there exists an
100
  equivalent-key group \[`Eb1`, `Eb2`) obtained from `b.equal_range(Ea1)`,
101
  such that `is_permutation(Ea1, Ea2, Eb1, Eb2)` returns `true`. For
102
  `unordered_set` and `unordered_map`, the complexity of `operator==`
103
  (i.e., the number of calls to the `==` operator of the `value_type`, to
104
- the predicate returned by `key_equal()`, and to the hasher returned by
105
  `hash_function()`) is proportional to N in the average case and to N² in
106
  the worst case, where N is a.size(). For `unordered_multiset` and
107
  `unordered_multimap`, the complexity of `operator==` is proportional to
108
  $\sum E_i^2$ in the average case and to N² in the worst case, where N is
109
  `a.size()`, and Eᵢ is the size of the iᵗʰ equivalent-key group in `a`.
@@ -114,31 +125,51 @@ same container), then the average-case complexity for
114
  `unordered_multiset` and `unordered_multimap` becomes proportional to N
115
  (but worst-case complexity remains 𝑂(N^2), e.g., for a pathologically
116
  bad hash function). The behavior of a program that uses `operator==` or
117
  `operator!=` on unordered containers is undefined unless the `Hash` and
118
  `Pred` function objects respectively have the same behavior for both
119
- containers and the equality comparison operator for `Key` is a
120
  refinement[^1] of the partition into equivalent-key groups produced by
121
  `Pred`.
122
 
123
  The iterator types `iterator` and `const_iterator` of an unordered
124
  associative container are of at least the forward iterator category. For
125
  unordered associative containers where the key type and value type are
126
- the same, both `iterator` and `const_iterator` are const iterators.
127
 
128
  The `insert` and `emplace` members shall not affect the validity of
129
  references to container elements, but may invalidate all iterators to
130
  the container. The `erase` members shall invalidate only iterators and
131
  references to the erased elements, and preserve the relative order of
132
  the elements that are not erased.
133
 
134
  The `insert` and `emplace` members shall not affect the validity of
135
- iterators if `(N+n) < z * B`, where `N` is the number of elements in the
136
- container prior to the insert operation, `n` is the number of elements
137
- inserted, `B` is the container’s bucket count, and `z` is the
138
  container’s maximum load factor.
139
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
140
  #### Exception safety guarantees <a id="unord.req.except">[[unord.req.except]]</a>
141
 
142
  For unordered associative containers, no `clear()` function throws an
143
  exception. `erase(k)` does not throw an exception unless that exception
144
  is thrown by the container’s `Hash` or `Pred` object (if any).
@@ -148,11 +179,11 @@ operation other than the container’s hash function from within an
148
  `insert` or `emplace` function inserting a single element, the insertion
149
  has no effect.
150
 
151
  For unordered associative containers, no `swap` function throws an
152
  exception unless that exception is thrown by the swap of the container’s
153
- Hash or Pred object (if any).
154
 
155
  For unordered associative containers, if an exception is thrown from
156
  within a `rehash()` function other than by the container’s hash function
157
  or comparison function, the `rehash()` function has no effect.
158
 
 
25
  the container.
26
 
27
  Two values `k1` and `k2` of type `Key` are considered equivalent if the
28
  container’s key equality predicate returns `true` when passed those
29
  values. If `k1` and `k2` are equivalent, the container’s hash function
30
+ shall return the same value for both.
31
+
32
+ [*Note 1*: Thus, when an unordered associative container is
33
+ instantiated with a non-default `Pred` parameter it usually needs a
34
+ non-default `Hash` parameter as well. *end note*]
35
+
36
+ For any two keys `k1` and `k2` in the same container, calling
37
+ `pred(k1, k2)` shall always return the same value. For any key `k` in a
38
+ container, calling `hash(k)` shall always return the same value.
39
 
40
  An unordered associative container supports *unique keys* if it may
41
  contain at most one element for each key. Otherwise, it supports
42
  *equivalent keys*. `unordered_set` and `unordered_map` support unique
43
  keys. `unordered_multiset` and `unordered_multimap` support equivalent
44
  keys. In containers that support equivalent keys, elements with
45
  equivalent keys are adjacent to each other in the iteration order of the
46
  container. Thus, although the absolute order of elements in an unordered
47
  container is not specified, its elements are grouped into
48
+ *equivalent-key groups* such that all elements of each group have
49
  equivalent keys. Mutating operations on unordered containers shall
50
  preserve the relative order of elements within each equivalent-key group
51
  unless otherwise specified.
52
 
53
  For `unordered_set` and `unordered_multiset` the value type is the same
54
  as the key type. For `unordered_map` and `unordered_multimap` it is
55
+ `pair<const Key,
56
  T>`.
57
 
58
  For unordered containers where the value type is the same as the key
59
  type, both `iterator` and `const_iterator` are constant iterators. It is
60
  unspecified whether or not `iterator` and `const_iterator` are the same
61
+ type.
62
+
63
+ [*Note 2*: `iterator` and `const_iterator` have identical semantics in
64
+ this case, and `iterator` is convertible to `const_iterator`. Users can
65
+ avoid violating the one-definition rule by always using `const_iterator`
66
+ in their function parameter lists. — *end note*]
67
 
68
  The elements of an unordered associative container are organized into
69
  *buckets*. Keys with the same hash code appear in the same bucket. The
70
  number of buckets is automatically increased as elements are added to an
71
  unordered associative container, so that the average number of elements
 
78
  The unordered associative containers meet all the requirements of
79
  Allocator-aware containers ([[container.requirements.general]]), except
80
  that for `unordered_map` and `unordered_multimap`, the requirements
81
  placed on `value_type` in Table 
82
  [[tab:containers.container.requirements]] apply instead to `key_type`
83
+ and `mapped_type`.
 
 
 
84
 
85
+ [*Note 3*: For example, `key_type` and `mapped_type` are sometimes
86
+ required to be `CopyAssignable` even though the associated `value_type`,
87
+ `pair<const key_type, mapped_type>`, is not
88
+ `CopyAssignable`. *end note*]
89
+
90
+ In Table  [[tab:HashRequirements]]: `X` denotes an unordered associative
91
+ container class, `a` denotes a value of type `X`, `a2` denotes a value
92
+ of a type with nodes compatible with type `X` (Table 
93
+ [[tab:containers.node.compat]]), `b` denotes a possibly const value of
94
+ type `X`, `a_uniq` denotes a value of type `X` when `X` supports unique
95
+ keys, `a_eq` denotes a value of type `X` when `X` supports equivalent
96
+ keys, `i` and `j` denote input iterators that refer to `value_type`,
97
+ `[i, j)` denotes a valid range, `p` and `q2` denote valid constant
98
+ iterators to `a`, `q` and `q1` denote valid dereferenceable constant
99
+ iterators to `a`, `r` denotes a valid dereferenceable iterator to `a`,
100
+ `[q1, q2)` denotes a valid range in `a`, `il` denotes a value of type
101
+ `initializer_list<value_type>`, `t` denotes a value of type
102
+ `X::value_type`, `k` denotes a value of type `key_type`, `hf` denotes a
103
+ possibly const value of type `hasher`, `eq` denotes a possibly const
104
+ value of type `key_equal`, `n` denotes a value of type `size_type`, `z`
105
+ denotes a value of type `float`, and `nh` denotes a non-const rvalue of
106
+ type `X::node_type`.
107
 
108
  Two unordered containers `a` and `b` compare equal if
109
  `a.size() == b.size()` and, for every equivalent-key group \[`Ea1`,
110
  `Ea2`) obtained from `a.equal_range(Ea1)`, there exists an
111
  equivalent-key group \[`Eb1`, `Eb2`) obtained from `b.equal_range(Ea1)`,
112
  such that `is_permutation(Ea1, Ea2, Eb1, Eb2)` returns `true`. For
113
  `unordered_set` and `unordered_map`, the complexity of `operator==`
114
  (i.e., the number of calls to the `==` operator of the `value_type`, to
115
+ the predicate returned by `key_eq()`, and to the hasher returned by
116
  `hash_function()`) is proportional to N in the average case and to N² in
117
  the worst case, where N is a.size(). For `unordered_multiset` and
118
  `unordered_multimap`, the complexity of `operator==` is proportional to
119
  $\sum E_i^2$ in the average case and to N² in the worst case, where N is
120
  `a.size()`, and Eᵢ is the size of the iᵗʰ equivalent-key group in `a`.
 
125
  `unordered_multiset` and `unordered_multimap` becomes proportional to N
126
  (but worst-case complexity remains 𝑂(N^2), e.g., for a pathologically
127
  bad hash function). The behavior of a program that uses `operator==` or
128
  `operator!=` on unordered containers is undefined unless the `Hash` and
129
  `Pred` function objects respectively have the same behavior for both
130
+ containers and the equality comparison function for `Key` is a
131
  refinement[^1] of the partition into equivalent-key groups produced by
132
  `Pred`.
133
 
134
  The iterator types `iterator` and `const_iterator` of an unordered
135
  associative container are of at least the forward iterator category. For
136
  unordered associative containers where the key type and value type are
137
+ the same, both `iterator` and `const_iterator` are constant iterators.
138
 
139
  The `insert` and `emplace` members shall not affect the validity of
140
  references to container elements, but may invalidate all iterators to
141
  the container. The `erase` members shall invalidate only iterators and
142
  references to the erased elements, and preserve the relative order of
143
  the elements that are not erased.
144
 
145
  The `insert` and `emplace` members shall not affect the validity of
146
+ iterators if `(N+n) <= z * B`, where `N` is the number of elements in
147
+ the container prior to the insert operation, `n` is the number of
148
+ elements inserted, `B` is the container’s bucket count, and `z` is the
149
  container’s maximum load factor.
150
 
151
+ The `extract` members invalidate only iterators to the removed element,
152
+ and preserve the relative order of the elements that are not erased;
153
+ pointers and references to the removed element remain valid. However,
154
+ accessing the element through such pointers and references while the
155
+ element is owned by a `node_type` is undefined behavior. References and
156
+ pointers to an element obtained while it is owned by a `node_type` are
157
+ invalidated if the element is successfully inserted.
158
+
159
+ A deduction guide for an unordered associative container shall not
160
+ participate in overload resolution if any of the following are true:
161
+
162
+ - It has an `InputIterator` template parameter and a type that does not
163
+ qualify as an input iterator is deduced for that parameter.
164
+ - It has an `Allocator` template parameter and a type that does not
165
+ qualify as an allocator is deduced for that parameter.
166
+ - It has a `Hash` template parameter and an integral type or a type that
167
+ qualifies as an allocator is deduced for that parameter.
168
+ - It has a `Pred` template parameter and a type that qualifies as an
169
+ allocator is deduced for that parameter.
170
+
171
  #### Exception safety guarantees <a id="unord.req.except">[[unord.req.except]]</a>
172
 
173
  For unordered associative containers, no `clear()` function throws an
174
  exception. `erase(k)` does not throw an exception unless that exception
175
  is thrown by the container’s `Hash` or `Pred` object (if any).
 
179
  `insert` or `emplace` function inserting a single element, the insertion
180
  has no effect.
181
 
182
  For unordered associative containers, no `swap` function throws an
183
  exception unless that exception is thrown by the swap of the container’s
184
+ `Hash` or `Pred` object (if any).
185
 
186
  For unordered associative containers, if an exception is thrown from
187
  within a `rehash()` function other than by the container’s hash function
188
  or comparison function, the `rehash()` function has no effect.
189