From Jason Turner

[flat.map.modifiers]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpwrxhphdw/{from.md → to.md} +31 -54
tmp/tmpwrxhphdw/{from.md → to.md} RENAMED
@@ -1,9 +1,9 @@
1
  #### Modifiers <a id="flat.map.modifiers">[[flat.map.modifiers]]</a>
2
 
3
  ``` cpp
4
- template<class... Args> pair<iterator, bool> emplace(Args&&... args);
5
  ```
6
 
7
  *Constraints:*
8
  `is_constructible_v<pair<key_type, mapped_type>, Args...>` is `true`.
9
 
@@ -22,12 +22,12 @@ c.values.insert(value_it, std::move(t.second));
22
  *Returns:* The `bool` component of the returned pair is `true` if and
23
  only if the insertion took place, and the iterator component of the pair
24
  points to the element with key equivalent to `t.first`.
25
 
26
  ``` cpp
27
- template<class P> pair<iterator, bool> insert(P&& x);
28
- template<class P> iterator insert(const_iterator position, P&& x);
29
  ```
30
 
31
  *Constraints:* `is_constructible_v<pair<key_type, mapped_type>, P>` is
32
  `true`.
33
 
@@ -35,14 +35,14 @@ template<class P> iterator insert(const_iterator position, P&& x);
35
  `return emplace(std::forward<P>(x));`. The second form is equivalent to
36
  `return emplace_hint(position, std::forward<P>(x));`.
37
 
38
  ``` cpp
39
  template<class InputIterator>
40
- void insert(InputIterator first, InputIterator last);
41
  ```
42
 
43
- *Effects:* Adds elements to `c` as if by:
44
 
45
  ``` cpp
46
  for (; first != last; ++first) {
47
  value_type value = *first;
48
  c.keys.insert(c.keys.end(), std::move(value.first));
@@ -54,12 +54,12 @@ Then, sorts the range of newly inserted elements with respect to
54
  `value_comp()`; merges the resulting sorted range and the sorted range
55
  of pre-existing elements into a single sorted range; and finally erases
56
  the duplicate elements as if by:
57
 
58
  ``` cpp
59
- auto zv = ranges::zip_view(c.keys, c.values);
60
- auto it = ranges::unique(zv, key_equiv(compare)).begin();
61
  auto dist = distance(zv.begin(), it);
62
  c.keys.erase(c.keys.begin() + dist, c.keys.end());
63
  c.values.erase(c.values.begin() + dist, c.values.end());
64
  ```
65
 
@@ -69,46 +69,23 @@ M is `distance(first, last)`.
69
  *Remarks:* Since this operation performs an in-place merge, it may
70
  allocate memory.
71
 
72
  ``` cpp
73
  template<class InputIterator>
74
- void insert(sorted_unique_t, InputIterator first, InputIterator last);
75
  ```
76
 
77
- *Effects:* Adds elements to `c` as if by:
78
-
79
- ``` cpp
80
- for (; first != last; ++first) {
81
- value_type value = *first;
82
- c.keys.insert(c.keys.end(), std::move(value.first));
83
- c.values.insert(c.values.end(), std::move(value.second));
84
- }
85
- ```
86
-
87
- Then, merges the sorted range of newly added elements and the sorted
88
- range of pre-existing elements into a single sorted range; and finally
89
- erases the duplicate elements as if by:
90
-
91
- ``` cpp
92
- auto zv = ranges::zip_view(c.keys, c.values);
93
- auto it = ranges::unique(zv, key_equiv(compare)).begin();
94
- auto dist = distance(zv.begin(), it);
95
- c.keys.erase(c.keys.begin() + dist, c.keys.end());
96
- c.values.erase(c.values.begin() + dist, c.values.end());
97
- ```
98
 
99
  *Complexity:* Linear in N, where N is `size()` after the operation.
100
 
101
- *Remarks:* Since this operation performs an in-place merge, it may
102
- allocate memory.
103
-
104
  ``` cpp
105
  template<container-compatible-range<value_type> R>
106
- void insert_range(R&& rg);
107
  ```
108
 
109
- *Effects:* Adds elements to `c` as if by:
110
 
111
  ``` cpp
112
  for (const auto& e : rg) {
113
  c.keys.insert(c.keys.end(), e.first);
114
  c.values.insert(c.values.end(), e.second);
@@ -119,12 +96,12 @@ Then, sorts the range of newly inserted elements with respect to
119
  `value_comp()`; merges the resulting sorted range and the sorted range
120
  of pre-existing elements into a single sorted range; and finally erases
121
  the duplicate elements as if by:
122
 
123
  ``` cpp
124
- auto zv = ranges::zip_view(c.keys, c.values);
125
- auto it = ranges::unique(zv, key_equiv(compare)).begin();
126
  auto dist = distance(zv.begin(), it);
127
  c.keys.erase(c.keys.begin() + dist, c.keys.end());
128
  c.values.erase(c.values.begin() + dist, c.values.end());
129
  ```
130
 
@@ -134,17 +111,17 @@ M is `ranges::distance(rg)`.
134
  *Remarks:* Since this operation performs an in-place merge, it may
135
  allocate memory.
136
 
137
  ``` cpp
138
  template<class... Args>
139
- pair<iterator, bool> try_emplace(const key_type& k, Args&&... args);
140
  template<class... Args>
141
- pair<iterator, bool> try_emplace(key_type&& k, Args&&... args);
142
  template<class... Args>
143
- iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args);
144
  template<class... Args>
145
- iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args);
146
  ```
147
 
148
  *Constraints:* `is_constructible_v<mapped_type, Args...>` is `true`.
149
 
150
  *Effects:* If the map already contains an element whose key is
@@ -166,13 +143,13 @@ returned iterator points to the map element whose key is equivalent to
166
  *Complexity:* The same as `emplace` for the first two overloads, and the
167
  same as `emplace_hint` for the last two overloads.
168
 
169
  ``` cpp
170
  template<class K, class... Args>
171
- pair<iterator, bool> try_emplace(K&& k, Args&&... args);
172
  template<class K, class... Args>
173
- iterator try_emplace(const_iterator hint, K&& k, Args&&... args);
174
  ```
175
 
176
  *Constraints:*
177
 
178
  - The *qualified-id* `Compare::is_transparent` is valid and denotes a
@@ -188,11 +165,11 @@ object `u`, for which `find(k) == find(u)` is `true`.
188
  *Effects:* If the map already contains an element whose key is
189
  equivalent to `k`, `*this` and `args...` are unchanged. Otherwise
190
  equivalent to:
191
 
192
  ``` cpp
193
- auto key_it = ranges::upper_bound(c.keys, k, compare);
194
  auto value_it = c.values.begin() + distance(c.keys.begin(), key_it);
195
  c.keys.emplace(key_it, std::forward<K>(k));
196
  c.values.emplace(value_it, std::forward<Args>(args)...);
197
  ```
198
 
@@ -202,17 +179,17 @@ iterator points to the map element whose key is equivalent to `k`.
202
 
203
  *Complexity:* The same as `emplace` and `emplace_hint`, respectively.
204
 
205
  ``` cpp
206
  template<class M>
207
- pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj);
208
  template<class M>
209
- pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj);
210
  template<class M>
211
- iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj);
212
  template<class M>
213
- iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj);
214
  ```
215
 
216
  *Constraints:* `is_assignable_v<mapped_type&, M>` is `true` and
217
  `is_constructible_v<mapped_type, M>` is `true`.
218
 
@@ -240,13 +217,13 @@ returned iterator points to the map element whose key is equivalent to
240
  *Complexity:* The same as `emplace` for the first two overloads and the
241
  same as `emplace_hint` for the last two overloads.
242
 
243
  ``` cpp
244
  template<class K, class M>
245
- pair<iterator, bool> insert_or_assign(K&& k, M&& obj);
246
  template<class K, class M>
247
- iterator insert_or_assign(const_iterator hint, K&& k, M&& obj);
248
  ```
249
 
250
  *Constraints:*
251
 
252
  - The *qualified-id* `Compare::is_transparent` is valid and denotes a
@@ -279,11 +256,11 @@ pair is `true` if and only if the insertion took place. The returned
279
  iterator points to the map element whose key is equivalent to `k`.
280
 
281
  *Complexity:* The same as `emplace` and `emplace_hint`, respectively.
282
 
283
  ``` cpp
284
- void swap(flat_map& y) noexcept;
285
  ```
286
 
287
  *Effects:* Equivalent to:
288
 
289
  ``` cpp
@@ -291,24 +268,24 @@ ranges::swap(compare, y.compare);
291
  ranges::swap(c.keys, y.c.keys);
292
  ranges::swap(c.values, y.c.values);
293
  ```
294
 
295
  ``` cpp
296
- containers extract() &&;
297
  ```
298
 
299
  *Ensures:* `*this` is emptied, even if the function exits via an
300
  exception.
301
 
302
- *Returns:* `std::move(c)`.
303
 
304
  ``` cpp
305
- void replace(key_container_type&& key_cont, mapped_container_type&& mapped_cont);
306
  ```
307
 
308
  *Preconditions:* `key_cont.size() == mapped_cont.size()` is `true`, the
309
- elements of `key_cont` are sorted with respect to `compare`, and
310
  `key_cont` contains no equal elements.
311
 
312
  *Effects:* Equivalent to:
313
 
314
  ``` cpp
 
1
  #### Modifiers <a id="flat.map.modifiers">[[flat.map.modifiers]]</a>
2
 
3
  ``` cpp
4
+ template<class... Args> constexpr pair<iterator, bool> emplace(Args&&... args);
5
  ```
6
 
7
  *Constraints:*
8
  `is_constructible_v<pair<key_type, mapped_type>, Args...>` is `true`.
9
 
 
22
  *Returns:* The `bool` component of the returned pair is `true` if and
23
  only if the insertion took place, and the iterator component of the pair
24
  points to the element with key equivalent to `t.first`.
25
 
26
  ``` cpp
27
+ template<class P> constexpr pair<iterator, bool> insert(P&& x);
28
+ template<class P> constexpr iterator insert(const_iterator position, P&& x);
29
  ```
30
 
31
  *Constraints:* `is_constructible_v<pair<key_type, mapped_type>, P>` is
32
  `true`.
33
 
 
35
  `return emplace(std::forward<P>(x));`. The second form is equivalent to
36
  `return emplace_hint(position, std::forward<P>(x));`.
37
 
38
  ``` cpp
39
  template<class InputIterator>
40
+ constexpr void insert(InputIterator first, InputIterator last);
41
  ```
42
 
43
+ *Effects:* Adds elements to *c* as if by:
44
 
45
  ``` cpp
46
  for (; first != last; ++first) {
47
  value_type value = *first;
48
  c.keys.insert(c.keys.end(), std::move(value.first));
 
54
  `value_comp()`; merges the resulting sorted range and the sorted range
55
  of pre-existing elements into a single sorted range; and finally erases
56
  the duplicate elements as if by:
57
 
58
  ``` cpp
59
+ auto zv = views::zip(c.keys, c.values);
60
+ auto it = ranges::unique(zv, key-equiv(compare)).begin();
61
  auto dist = distance(zv.begin(), it);
62
  c.keys.erase(c.keys.begin() + dist, c.keys.end());
63
  c.values.erase(c.values.begin() + dist, c.values.end());
64
  ```
65
 
 
69
  *Remarks:* Since this operation performs an in-place merge, it may
70
  allocate memory.
71
 
72
  ``` cpp
73
  template<class InputIterator>
74
+ constexpr void insert(sorted_unique_t, InputIterator first, InputIterator last);
75
  ```
76
 
77
+ *Effects:* Equivalent to `insert(first, last)`.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
 
79
  *Complexity:* Linear in N, where N is `size()` after the operation.
80
 
 
 
 
81
  ``` cpp
82
  template<container-compatible-range<value_type> R>
83
+ constexpr void insert_range(R&& rg);
84
  ```
85
 
86
+ *Effects:* Adds elements to *c* as if by:
87
 
88
  ``` cpp
89
  for (const auto& e : rg) {
90
  c.keys.insert(c.keys.end(), e.first);
91
  c.values.insert(c.values.end(), e.second);
 
96
  `value_comp()`; merges the resulting sorted range and the sorted range
97
  of pre-existing elements into a single sorted range; and finally erases
98
  the duplicate elements as if by:
99
 
100
  ``` cpp
101
+ auto zv = views::zip(c.keys, c.values);
102
+ auto it = ranges::unique(zv, key-equiv(compare)).begin();
103
  auto dist = distance(zv.begin(), it);
104
  c.keys.erase(c.keys.begin() + dist, c.keys.end());
105
  c.values.erase(c.values.begin() + dist, c.values.end());
106
  ```
107
 
 
111
  *Remarks:* Since this operation performs an in-place merge, it may
112
  allocate memory.
113
 
114
  ``` cpp
115
  template<class... Args>
116
+ constexpr pair<iterator, bool> try_emplace(const key_type& k, Args&&... args);
117
  template<class... Args>
118
+ constexpr pair<iterator, bool> try_emplace(key_type&& k, Args&&... args);
119
  template<class... Args>
120
+ constexpr iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args);
121
  template<class... Args>
122
+ constexpr iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args);
123
  ```
124
 
125
  *Constraints:* `is_constructible_v<mapped_type, Args...>` is `true`.
126
 
127
  *Effects:* If the map already contains an element whose key is
 
143
  *Complexity:* The same as `emplace` for the first two overloads, and the
144
  same as `emplace_hint` for the last two overloads.
145
 
146
  ``` cpp
147
  template<class K, class... Args>
148
+ constexpr pair<iterator, bool> try_emplace(K&& k, Args&&... args);
149
  template<class K, class... Args>
150
+ constexpr iterator try_emplace(const_iterator hint, K&& k, Args&&... args);
151
  ```
152
 
153
  *Constraints:*
154
 
155
  - The *qualified-id* `Compare::is_transparent` is valid and denotes a
 
165
  *Effects:* If the map already contains an element whose key is
166
  equivalent to `k`, `*this` and `args...` are unchanged. Otherwise
167
  equivalent to:
168
 
169
  ``` cpp
170
+ auto key_it = upper_bound(c.keys.begin(), c.keys.end(), k, compare);
171
  auto value_it = c.values.begin() + distance(c.keys.begin(), key_it);
172
  c.keys.emplace(key_it, std::forward<K>(k));
173
  c.values.emplace(value_it, std::forward<Args>(args)...);
174
  ```
175
 
 
179
 
180
  *Complexity:* The same as `emplace` and `emplace_hint`, respectively.
181
 
182
  ``` cpp
183
  template<class M>
184
+ constexpr pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj);
185
  template<class M>
186
+ constexpr pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj);
187
  template<class M>
188
+ constexpr iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj);
189
  template<class M>
190
+ constexpr iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj);
191
  ```
192
 
193
  *Constraints:* `is_assignable_v<mapped_type&, M>` is `true` and
194
  `is_constructible_v<mapped_type, M>` is `true`.
195
 
 
217
  *Complexity:* The same as `emplace` for the first two overloads and the
218
  same as `emplace_hint` for the last two overloads.
219
 
220
  ``` cpp
221
  template<class K, class M>
222
+ constexpr pair<iterator, bool> insert_or_assign(K&& k, M&& obj);
223
  template<class K, class M>
224
+ constexpr iterator insert_or_assign(const_iterator hint, K&& k, M&& obj);
225
  ```
226
 
227
  *Constraints:*
228
 
229
  - The *qualified-id* `Compare::is_transparent` is valid and denotes a
 
256
  iterator points to the map element whose key is equivalent to `k`.
257
 
258
  *Complexity:* The same as `emplace` and `emplace_hint`, respectively.
259
 
260
  ``` cpp
261
+ constexpr void swap(flat_map& y) noexcept;
262
  ```
263
 
264
  *Effects:* Equivalent to:
265
 
266
  ``` cpp
 
268
  ranges::swap(c.keys, y.c.keys);
269
  ranges::swap(c.values, y.c.values);
270
  ```
271
 
272
  ``` cpp
273
+ constexpr containers extract() &&;
274
  ```
275
 
276
  *Ensures:* `*this` is emptied, even if the function exits via an
277
  exception.
278
 
279
+ *Returns:* `std::move(`*`c`*`)`.
280
 
281
  ``` cpp
282
+ constexpr void replace(key_container_type&& key_cont, mapped_container_type&& mapped_cont);
283
  ```
284
 
285
  *Preconditions:* `key_cont.size() == mapped_cont.size()` is `true`, the
286
+ elements of `key_cont` are sorted with respect to *compare*, and
287
  `key_cont` contains no equal elements.
288
 
289
  *Effects:* Equivalent to:
290
 
291
  ``` cpp