From Jason Turner

[associative.reqmts]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpao4qhl2j/{from.md → to.md} +728 -38
tmp/tmpao4qhl2j/{from.md → to.md} RENAMED
@@ -1,10 +1,16 @@
1
  ### Associative containers <a id="associative.reqmts">[[associative.reqmts]]</a>
2
 
 
 
3
  Associative containers provide fast retrieval of data based on keys. The
4
  library provides four basic kinds of associative containers: `set`,
5
- `multiset`, `map` and `multimap`.
 
 
 
 
6
 
7
  Each associative container is parameterized on `Key` and an ordering
8
  relation `Compare` that induces a strict weak ordering [[alg.sorting]]
9
  on elements of `Key`. In addition, `map` and `multimap` associate an
10
  arbitrary *mapped type* `T` with the `Key`. The object of type `Compare`
@@ -42,50 +48,729 @@ type.
42
  [*Note 2*: `iterator` and `const_iterator` have identical semantics in
43
  this case, and `iterator` is convertible to `const_iterator`. Users can
44
  avoid violating the one-definition rule by always using `const_iterator`
45
  in their function parameter lists. — *end note*]
46
 
47
- The associative containers meet all the requirements of Allocator-aware
48
- containers [[container.requirements.general]], except that for `map` and
49
- `multimap`, the requirements placed on `value_type` in
50
- [[container.alloc.req]] apply instead to `key_type` and `mapped_type`.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
 
52
  [*Note 3*: For example, in some cases `key_type` and `mapped_type` are
53
  required to be *Cpp17CopyAssignable* even though the associated
54
  `value_type`, `pair<const key_type, mapped_type>`, is not
55
  *Cpp17CopyAssignable*. — *end note*]
56
 
57
- In [[container.assoc.req]], `X` denotes an associative container class,
58
- `a` denotes a value of type `X`, `a2` denotes a value of a type with
59
- nodes compatible with type `X` ([[container.node.compat]]), `b` denotes
60
- a possibly `const` value of type `X`, `u` denotes the name of a variable
61
- being declared, `a_uniq` denotes a value of type `X` when `X` supports
62
- unique keys, `a_eq` denotes a value of type `X` when `X` supports
63
- multiple keys, `a_tran` denotes a possibly `const` value of type `X`
64
- when the *qualified-id* `X::key_compare::is_transparent` is valid and
65
- denotes a type [[temp.deduct]], `i` and `j` meet the
66
- *Cpp17InputIterator* requirements and refer to elements implicitly
67
- convertible to `value_type`, \[`i`, `j`) denotes a valid range, `p`
68
- denotes a valid constant iterator to `a`, `q` denotes a valid
69
- dereferenceable constant iterator to `a`, `r` denotes a valid
70
- dereferenceable iterator to `a`, `[q1, q2)` denotes a valid range of
71
- constant iterators in `a`, `il` designates an object of type
72
- `initializer_list<value_type>`, `t` denotes a value of type
73
- `X::value_type`, `k` denotes a value of type `X::key_type` and `c`
74
- denotes a possibly `const` value of type `X::key_compare`; `kl` is a
75
- value such that `a` is partitioned [[alg.sorting]] with respect to
76
- `c(r, kl)`, with `r` the key value of `e` and `e` in `a`; `ku` is a
77
- value such that `a` is partitioned with respect to `!c(ku, r)`; `ke` is
78
- a value such that `a` is partitioned with respect to `c(r, ke)` and
79
- `!c(ke, r)`, with `c(r, ke)` implying `!c(ke, r)`. `A` denotes the
80
- storage allocator used by `X`, if any, or `allocator<X::value_type>`
81
- otherwise, `m` denotes an allocator of a type convertible to `A`, and
82
- `nh` denotes a non-const rvalue of type `X::node_type`.
83
-
84
- The `insert` and `emplace` members shall not affect the validity of
85
- iterators and references to the container, and the `erase` members shall
86
- invalidate only iterators and references to the erased elements.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
 
88
  The `extract` members invalidate only iterators to the removed element;
89
  pointers and references to the removed element remain valid. However,
90
  accessing the element through such pointers and references while the
91
  element is owned by a `node_type` is undefined behavior. References and
@@ -117,13 +802,18 @@ associative container is copied, through either a copy constructor or an
117
  assignment operator, the target container shall then use the comparison
118
  object from the container being copied, as if that comparison object had
119
  been passed to the target container in its constructor.
120
 
121
  The member function templates `find`, `count`, `contains`,
122
- `lower_bound`, `upper_bound`, and `equal_range` shall not participate in
123
- overload resolution unless the *qualified-id* `Compare::is_transparent`
124
- is valid and denotes a type [[temp.deduct]].
 
 
 
 
 
125
 
126
  A deduction guide for an associative container shall not participate in
127
  overload resolution if any of the following are true:
128
 
129
  - It has an `InputIterator` template parameter and a type that does not
 
1
  ### Associative containers <a id="associative.reqmts">[[associative.reqmts]]</a>
2
 
3
+ #### General <a id="associative.reqmts.general">[[associative.reqmts.general]]</a>
4
+
5
  Associative containers provide fast retrieval of data based on keys. The
6
  library provides four basic kinds of associative containers: `set`,
7
+ `multiset`, `map` and `multimap`. The library also provides container
8
+ adaptors that make it easy to construct abstract data types, such as
9
+ `flat_map`s, `flat_multimap`s, `flat_set`s, or `flat_multiset`s, out of
10
+ the basic sequence container kinds (or out of other program-defined
11
+ sequence containers).
12
 
13
  Each associative container is parameterized on `Key` and an ordering
14
  relation `Compare` that induces a strict weak ordering [[alg.sorting]]
15
  on elements of `Key`. In addition, `map` and `multimap` associate an
16
  arbitrary *mapped type* `T` with the `Key`. The object of type `Compare`
 
48
  [*Note 2*: `iterator` and `const_iterator` have identical semantics in
49
  this case, and `iterator` is convertible to `const_iterator`. Users can
50
  avoid violating the one-definition rule by always using `const_iterator`
51
  in their function parameter lists. — *end note*]
52
 
53
+ In this subclause,
54
+
55
+ - `X` denotes an associative container class,
56
+ - `a` denotes a value of type `X`,
57
+ - `a2` denotes a value of a type with nodes compatible with type `X` (
58
+ [[container.node.compat]]),
59
+ - `b` denotes a value or type `X` or `const X`,
60
+ - `u` denotes the name of a variable being declared,
61
+ - `a_uniq` denotes a value of type `X` when `X` supports unique keys,
62
+ - `a_eq` denotes a value of type `X` when `X` supports multiple keys,
63
+ - `a_tran` denotes a value of type `X` or `const X` when the
64
+ *qualified-id* `X::key_compare::is_transparent` is valid and denotes a
65
+ type [[temp.deduct]],
66
+ - `i` and `j` meet the *Cpp17InputIterator* requirements and refer to
67
+ elements implicitly convertible to `value_type`,
68
+ - \[`i`, `j`) denotes a valid range,
69
+ - `rg` denotes a value of a type `R` that models
70
+ `container-compatible-range<value_type>`,
71
+ - `p` denotes a valid constant iterator to `a`,
72
+ - `q` denotes a valid dereferenceable constant iterator to `a`,
73
+ - `r` denotes a valid dereferenceable iterator to `a`,
74
+ - `[q1, q2)` denotes a valid range of constant iterators in `a`,
75
+ - `il` designates an object of type `initializer_list<value_type>`,
76
+ - `t` denotes a value of type `X::value_type`,
77
+ - `k` denotes a value of type `X::key_type`, and
78
+ - `c` denotes a value of type `X::key_compare` or
79
+ `const X::key_compare`;
80
+ - `kl` is a value such that `a` is partitioned [[alg.sorting]] with
81
+ respect to `c(x, kl)`, with `x` the key value of `e` and `e` in `a`;
82
+ - `ku` is a value such that `a` is partitioned with respect to
83
+ `!c(ku, x)`, with `x` the key value of `e` and `e` in `a`;
84
+ - `ke` is a value such that `a` is partitioned with respect to
85
+ `c(x, ke)` and `!c(ke, x)`, with `c(x, ke)` implying `!c(ke, x)` and
86
+ with `x` the key value of `e` and `e` in `a`;
87
+ - `kx` is a value such that
88
+ - `a` is partitioned with respect to `c(x, kx)` and `!c(kx, x)`, with
89
+ `c(x, kx)` implying `!c(kx, x)` and with `x` the key value of `e`
90
+ and `e` in `a`, and
91
+ - `kx` is not convertible to either `iterator` or `const_iterator`;
92
+ and
93
+ - `A` denotes the storage allocator used by `X`, if any, or
94
+ `allocator<X::value_type>` otherwise,
95
+ - `m` denotes an allocator of a type convertible to `A`, and `nh`
96
+ denotes a non-const rvalue of type `X::node_type`.
97
+
98
+ A type `X` meets the *associative container* requirements if `X` meets
99
+ all the requirements of an allocator-aware container
100
+ [[container.requirements.general]] and the following types, statements,
101
+ and expressions are well-formed and have the specified semantics, except
102
+ that for `map` and `multimap`, the requirements placed on `value_type`
103
+ in [[container.alloc.reqmts]] apply instead to `key_type` and
104
+ `mapped_type`.
105
 
106
  [*Note 3*: For example, in some cases `key_type` and `mapped_type` are
107
  required to be *Cpp17CopyAssignable* even though the associated
108
  `value_type`, `pair<const key_type, mapped_type>`, is not
109
  *Cpp17CopyAssignable*. — *end note*]
110
 
111
+ ``` cpp
112
+ typename X::key_type
113
+ ```
114
+
115
+ *Result:* `Key`.
116
+
117
+ ``` cpp
118
+ typename X::mapped_type
119
+ ```
120
+
121
+ *Result:* `T`.
122
+
123
+ *Remarks:* For `map` and `multimap` only.
124
+
125
+ ``` cpp
126
+ typename X::value_type
127
+ ```
128
+
129
+ *Result:* `Key` for `set` and `multiset` only; `pair<const Key, T>` for
130
+ `map` and `multimap` only.
131
+
132
+ *Preconditions:* `X::value_type` is *Cpp17Erasable* from `X`.
133
+
134
+ ``` cpp
135
+ typename X::key_compare
136
+ ```
137
+
138
+ *Result:* `Compare`.
139
+
140
+ *Preconditions:* `key_compare` is *Cpp17CopyConstructible*.
141
+
142
+ ``` cpp
143
+ typename X::value_compare
144
+ ```
145
+
146
+ *Result:* A binary predicate type. It is the same as `key_compare` for
147
+ `set` and `multiset`; is an ordering relation on pairs induced by the
148
+ first component (i.e., `Key`) for `map` and `multimap`.
149
+
150
+ ``` cpp
151
+ typename X::node_type
152
+ ```
153
+
154
+ *Result:* A specialization of the *node-handle* class
155
+ template [[container.node]], such that the public nested types are the
156
+ same types as the corresponding types in `X`.
157
+
158
+ ``` cpp
159
+ X(c)
160
+ ```
161
+
162
+ *Effects:* Constructs an empty container. Uses a copy of `c` as a
163
+ comparison object.
164
+
165
+ *Complexity:* Constant.
166
+
167
+ ``` cpp
168
+ X u = X();
169
+ X u;
170
+ ```
171
+
172
+ *Preconditions:* `key_compare` meets the *Cpp17DefaultConstructible*
173
+ requirements.
174
+
175
+ *Effects:* Constructs an empty container. Uses `Compare()` as a
176
+ comparison object.
177
+
178
+ *Complexity:* Constant.
179
+
180
+ ``` cpp
181
+ X(i, j, c)
182
+ ```
183
+
184
+ *Preconditions:* `value_type` is *Cpp17EmplaceConstructible* into `X`
185
+ from `*i`.
186
+
187
+ *Effects:* Constructs an empty container and inserts elements from the
188
+ range \[`i`, `j`) into it; uses `c` as a comparison object.
189
+
190
+ *Complexity:* N log N in general, where N has the value
191
+ `distance(i, j)`; linear if \[`i`, `j`) is sorted with respect to
192
+ `value_comp()`.
193
+
194
+ ``` cpp
195
+ X(i, j)
196
+ ```
197
+
198
+ *Preconditions:* `key_compare` meets the *Cpp17DefaultConstructible*
199
+ requirements. `value_type` is *Cpp17EmplaceConstructible* into `X` from
200
+ `*i`.
201
+
202
+ *Effects:* Constructs an empty container and inserts elements from the
203
+ range \[`i`, `j`) into it; uses `Compare()` as a comparison object.
204
+
205
+ *Complexity:* N log N in general, where N has the value
206
+ `distance(i, j)`; linear if \[`i`, `j`) is sorted with respect to
207
+ `value_comp()`.
208
+
209
+ ``` cpp
210
+ X(from_range, rg, c)
211
+ ```
212
+
213
+ *Preconditions:* `value_type` is *Cpp17EmplaceConstructible* into `X`
214
+ from `*ranges::begin(rg)`.
215
+
216
+ *Effects:* Constructs an empty container and inserts each element from
217
+ `rg` into it. Uses `c` as the comparison object.
218
+
219
+ *Complexity:* N log N in general, where N has the value
220
+ `ranges::distance(rg)`; linear if `rg` is sorted with respect to
221
+ `value_comp()`.
222
+
223
+ ``` cpp
224
+ X(from_range, rg)
225
+ ```
226
+
227
+ *Preconditions:* `key_compare` meets the *Cpp17DefaultConstructible*
228
+ requirements. `value_type` is *Cpp17EmplaceConstructible* into `X` from
229
+ `*ranges::begin(rg)`.
230
+
231
+ *Effects:* Constructs an empty container and inserts each element from
232
+ `rg` into it. Uses `Compare()` as the comparison object.
233
+
234
+ *Complexity:* Same as `X(from_range, rg, c)`.
235
+
236
+ ``` cpp
237
+ X(il, c)
238
+ ```
239
+
240
+ *Effects:* Equivalent to `X(il.begin(), il.end(), c)`.
241
+
242
+ ``` cpp
243
+ X(il)
244
+ ```
245
+
246
+ *Effects:* Equivalent to `X(il.begin(), il.end())`.
247
+
248
+ ``` cpp
249
+ a = il
250
+ ```
251
+
252
+ *Result:* `X&`
253
+
254
+ *Preconditions:* `value_type` is *Cpp17CopyInsertable* into `X` and
255
+ *Cpp17CopyAssignable*.
256
+
257
+ *Effects:* Assigns the range \[`il.begin()`, `il.end()`) into `a`. All
258
+ existing elements of `a` are either assigned to or destroyed.
259
+
260
+ *Complexity:* N log N in general, where N has the value
261
+ `il.size() + a.size()`; linear if \[`il.begin()`, `il.end()`) is sorted
262
+ with respect to `value_comp()`.
263
+
264
+ ``` cpp
265
+ b.key_comp()
266
+ ```
267
+
268
+ *Result:* `X::key_compare`
269
+
270
+ *Returns:* The comparison object out of which `b` was constructed.
271
+
272
+ *Complexity:* Constant.
273
+
274
+ ``` cpp
275
+ b.value_comp()
276
+ ```
277
+
278
+ *Result:* `X::value_compare`
279
+
280
+ *Returns:* An object of `value_compare` constructed out of the
281
+ comparison object.
282
+
283
+ *Complexity:* Constant.
284
+
285
+ ``` cpp
286
+ a_uniq.emplace(args)
287
+ ```
288
+
289
+ *Result:* `pair<iterator, bool>`
290
+
291
+ *Preconditions:* `value_type` is *Cpp17EmplaceConstructible* into `X`
292
+ from `args`.
293
+
294
+ *Effects:* Inserts a `value_type` object `t` constructed with
295
+ `std::forward<Args>(args)...` if and only if there is no element in the
296
+ container with key equivalent to the key of `t`.
297
+
298
+ *Returns:* The `bool` component of the returned pair is `true` if and
299
+ only if the insertion takes place, and the iterator component of the
300
+ pair points to the element with key equivalent to the key of `t`.
301
+
302
+ *Complexity:* Logarithmic.
303
+
304
+ ``` cpp
305
+ a_eq.emplace(args)
306
+ ```
307
+
308
+ *Result:* `iterator`
309
+
310
+ *Preconditions:* `value_type` is *Cpp17EmplaceConstructible* into `X`
311
+ from `args`.
312
+
313
+ *Effects:* Inserts a `value_type` object `t` constructed with
314
+ `std::forward<Args>(args)...`. If a range containing elements equivalent
315
+ to `t` exists in `a_eq`, `t` is inserted at the end of that range.
316
+
317
+ *Returns:* An iterator pointing to the newly inserted element.
318
+
319
+ *Complexity:* Logarithmic.
320
+
321
+ ``` cpp
322
+ a.emplace_hint(p, args)
323
+ ```
324
+
325
+ *Result:* `iterator`
326
+
327
+ *Effects:* Equivalent to `a.emplace(std::forward<Args>(args)...)`,
328
+ except that the element is inserted as close as possible to the position
329
+ just prior to `p`.
330
+
331
+ *Returns:* An iterator pointing to the element with the key equivalent
332
+ to the newly inserted element.
333
+
334
+ *Complexity:* Logarithmic in general, but amortized constant if the
335
+ element is inserted right before `p`.
336
+
337
+ ``` cpp
338
+ a_uniq.insert(t)
339
+ ```
340
+
341
+ *Result:* `pair<iterator, bool>`
342
+
343
+ *Preconditions:* If `t` is a non-const rvalue, `value_type` is
344
+ *Cpp17MoveInsertable* into `X`; otherwise, `value_type` is
345
+ *Cpp17CopyInsertable* into `X`.
346
+
347
+ *Effects:* Inserts `t` if and only if there is no element in the
348
+ container with key equivalent to the key of `t`.
349
+
350
+ *Returns:* The `bool` component of the returned pair is `true` if and
351
+ only if the insertion takes place, and the `iterator` component of the
352
+ pair points to the element with key equivalent to the key of `t`.
353
+
354
+ *Complexity:* Logarithmic.
355
+
356
+ ``` cpp
357
+ a_eq.insert(t)
358
+ ```
359
+
360
+ *Result:* `iterator`
361
+
362
+ *Preconditions:* If `t` is a non-const rvalue, `value_type` is
363
+ *Cpp17MoveInsertable* into `X`; otherwise, `value_type` is
364
+ *Cpp17CopyInsertable* into `X`.
365
+
366
+ *Effects:* Inserts `t` and returns the iterator pointing to the newly
367
+ inserted element. If a range containing elements equivalent to `t`
368
+ exists in `a_eq`, `t` is inserted at the end of that range.
369
+
370
+ *Complexity:* Logarithmic.
371
+
372
+ ``` cpp
373
+ a.insert(p, t)
374
+ ```
375
+
376
+ *Result:* `iterator`
377
+
378
+ *Preconditions:* If `t` is a non-const rvalue, `value_type` is
379
+ *Cpp17MoveInsertable* into `X`; otherwise, `value_type` is
380
+ *Cpp17CopyInsertable* into `X`.
381
+
382
+ *Effects:* Inserts `t` if and only if there is no element with key
383
+ equivalent to the key of `t` in containers with unique keys; always
384
+ inserts `t` in containers with equivalent keys. `t` is inserted as close
385
+ as possible to the position just prior to `p`.
386
+
387
+ *Returns:* An iterator pointing to the element with key equivalent to
388
+ the key of `t`.
389
+
390
+ *Complexity:* Logarithmic in general, but amortized constant if `t` is
391
+ inserted right before `p`.
392
+
393
+ ``` cpp
394
+ a.insert(i, j)
395
+ ```
396
+
397
+ *Result:* `void`
398
+
399
+ *Preconditions:* `value_type` is *Cpp17EmplaceConstructible* into `X`
400
+ from `*i`. Neither `i` nor `j` are iterators into `a`.
401
+
402
+ *Effects:* Inserts each element from the range \[`i`, `j`) if and only
403
+ if there is no element with key equivalent to the key of that element in
404
+ containers with unique keys; always inserts that element in containers
405
+ with equivalent keys.
406
+
407
+ *Complexity:* N log (`a.size()` + N), where N has the value
408
+ `distance(i, j)`.
409
+
410
+ ``` cpp
411
+ a.insert_range(rg)
412
+ ```
413
+
414
+ *Result:* `void`
415
+
416
+ *Preconditions:* `value_type` is *Cpp17EmplaceConstructible* into `X`
417
+ from `*ranges::begin(rg)`. `rg` and `a` do not overlap.
418
+
419
+ *Effects:* Inserts each element from `rg` if and only if there is no
420
+ element with key equivalent to the key of that element in containers
421
+ with unique keys; always inserts that element in containers with
422
+ equivalent keys.
423
+
424
+ *Complexity:* N log (`a.size()` + N), where N has the value
425
+ `ranges::distance(rg)`.
426
+
427
+ ``` cpp
428
+ a.insert(il)
429
+ ```
430
+
431
+ *Effects:* Equivalent to `a.insert(il.begin(), il.end())`.
432
+
433
+ ``` cpp
434
+ a_uniq.insert(nh)
435
+ ```
436
+
437
+ *Result:* `insert_return_type`
438
+
439
+ *Preconditions:* `nh` is empty or
440
+ `a_uniq.get_allocator() == nh.get_allocator()` is `true`.
441
+
442
+ *Effects:* If `nh` is empty, has no effect. Otherwise, inserts the
443
+ element owned by `nh` if and only if there is no element in the
444
+ container with a key equivalent to `nh.key()`.
445
+
446
+ *Returns:* If `nh` is empty, `inserted` is `false`, `position` is
447
+ `end()`, and `node` is empty. Otherwise if the insertion took place,
448
+ `inserted` is `true`, `position` points to the inserted element, and
449
+ `node` is empty; if the insertion failed, `inserted` is `false`, `node`
450
+ has the previous value of `nh`, and `position` points to an element with
451
+ a key equivalent to `nh.key()`.
452
+
453
+ *Complexity:* Logarithmic.
454
+
455
+ ``` cpp
456
+ a_eq.insert(nh)
457
+ ```
458
+
459
+ *Result:* `iterator`
460
+
461
+ *Preconditions:* `nh` is empty or
462
+ `a_eq.get_allocator() == nh.get_allocator()` is `true`.
463
+
464
+ *Effects:* If `nh` is empty, has no effect and returns `a_eq.end()`.
465
+ Otherwise, inserts the element owned by `nh` and returns an iterator
466
+ pointing to the newly inserted element. If a range containing elements
467
+ with keys equivalent to `nh.key()` exists in `a_eq`, the element is
468
+ inserted at the end of that range.
469
+
470
+ *Ensures:* `nh` is empty.
471
+
472
+ *Complexity:* Logarithmic.
473
+
474
+ ``` cpp
475
+ a.insert(p, nh)
476
+ ```
477
+
478
+ *Result:* `iterator`
479
+
480
+ *Preconditions:* `nh` is empty or
481
+ `a.get_allocator() == nh.get_allocator()` is `true`.
482
+
483
+ *Effects:* If `nh` is empty, has no effect and returns `a.end()`.
484
+ Otherwise, inserts the element owned by `nh` if and only if there is no
485
+ element with key equivalent to `nh.key()` in containers with unique
486
+ keys; always inserts the element owned by `nh` in containers with
487
+ equivalent keys. The element is inserted as close as possible to the
488
+ position just prior to `p`.
489
+
490
+ *Ensures:* `nh` is empty if insertion succeeds, unchanged if insertion
491
+ fails.
492
+
493
+ *Returns:* An iterator pointing to the element with key equivalent to
494
+ `nh.key()`.
495
+
496
+ *Complexity:* Logarithmic in general, but amortized constant if the
497
+ element is inserted right before `p`.
498
+
499
+ ``` cpp
500
+ a.extract(k)
501
+ ```
502
+
503
+ *Result:* `node_type`
504
+
505
+ *Effects:* Removes the first element in the container with key
506
+ equivalent to `k`.
507
+
508
+ *Returns:* A `node_type` owning the element if found, otherwise an empty
509
+ `node_type`.
510
+
511
+ *Complexity:* log (`a.size()`)
512
+
513
+ ``` cpp
514
+ a_tran.extract(kx)
515
+ ```
516
+
517
+ *Result:* `node_type`
518
+
519
+ *Effects:* Removes the first element in the container with key `r` such
520
+ that `!c(r, kx) && !c(kx, r)` is `true`.
521
+
522
+ *Returns:* A `node_type` owning the element if found, otherwise an empty
523
+ `node_type`.
524
+
525
+ *Complexity:* log(`a_tran.size()`)
526
+
527
+ ``` cpp
528
+ a.extract(q)
529
+ ```
530
+
531
+ *Result:* `node_type`
532
+
533
+ *Effects:* Removes the element pointed to by `q`.
534
+
535
+ *Returns:* A `node_type` owning that element.
536
+
537
+ *Complexity:* Amortized constant.
538
+
539
+ ``` cpp
540
+ a.merge(a2)
541
+ ```
542
+
543
+ *Result:* `void`
544
+
545
+ *Preconditions:* `a.get_allocator() == a2.get_allocator()`.
546
+
547
+ *Effects:* Attempts to extract each element in `a2` and insert it into
548
+ `a` using the comparison object of `a`. In containers with unique keys,
549
+ if there is an element in `a` with key equivalent to the key of an
550
+ element from `a2`, then that element is not extracted from `a2`.
551
+
552
+ *Ensures:* Pointers and references to the transferred elements of `a2`
553
+ refer to those same elements but as members of `a`. Iterators referring
554
+ to the transferred elements will continue to refer to their elements,
555
+ but they now behave as iterators into `a`, not into `a2`.
556
+
557
+ *Throws:* Nothing unless the comparison object throws.
558
+
559
+ *Complexity:* N log(`a.size()+` N), where N has the value `a2.size()`.
560
+
561
+ ``` cpp
562
+ a.erase(k)
563
+ ```
564
+
565
+ *Result:* `size_type`
566
+
567
+ *Effects:* Erases all elements in the container with key equivalent to
568
+ `k`.
569
+
570
+ *Returns:* The number of erased elements.
571
+
572
+ *Complexity:* log (`a.size()`) + `a.count(k)`
573
+
574
+ ``` cpp
575
+ a_tran.erase(kx)
576
+ ```
577
+
578
+ *Result:* `size_type`
579
+
580
+ *Effects:* Erases all elements in the container with key `r` such that
581
+ `!c(r, kx) && !c(kx, r)` is `true`.
582
+
583
+ *Returns:* The number of erased elements.
584
+
585
+ *Complexity:* log(`a_tran.size())` + `a_tran.count(kx)`
586
+
587
+ ``` cpp
588
+ a.erase(q)
589
+ ```
590
+
591
+ *Result:* `iterator`
592
+
593
+ *Effects:* Erases the element pointed to by `q`.
594
+
595
+ *Returns:* An iterator pointing to the element immediately following `q`
596
+ prior to the element being erased. If no such element exists, returns
597
+ `a.end()`.
598
+
599
+ *Complexity:* Amortized constant.
600
+
601
+ ``` cpp
602
+ a.erase(r)
603
+ ```
604
+
605
+ *Result:* `iterator`
606
+
607
+ *Effects:* Erases the element pointed to by `r`.
608
+
609
+ *Returns:* An iterator pointing to the element immediately following `r`
610
+ prior to the element being erased. If no such element exists, returns
611
+ `a.end()`.
612
+
613
+ *Complexity:* Amortized constant.
614
+
615
+ ``` cpp
616
+ a.erase(q1, q2)
617
+ ```
618
+
619
+ *Result:* `iterator`
620
+
621
+ *Effects:* Erases all the elements in the range \[`q1`, `q2`).
622
+
623
+ *Returns:* An iterator pointing to the element pointed to by `q2` prior
624
+ to any elements being erased. If no such element exists, `a.end()` is
625
+ returned.
626
+
627
+ *Complexity:* log(`a.size()`) + N, where N has the value
628
+ `distance(q1, q2)`.
629
+
630
+ ``` cpp
631
+ a.clear()
632
+ ```
633
+
634
+ *Effects:* Equivalent to `a.erase(a.begin(), a.end())`.
635
+
636
+ *Ensures:* `a.empty()` is `true`.
637
+
638
+ *Complexity:* Linear in `a.size()`.
639
+
640
+ ``` cpp
641
+ b.find(k)
642
+ ```
643
+
644
+ *Result:* `iterator`; `const_iterator` for constant `b`.
645
+
646
+ *Returns:* An iterator pointing to an element with the key equivalent to
647
+ `k`, or `b.end()` if such an element is not found.
648
+
649
+ *Complexity:* Logarithmic.
650
+
651
+ ``` cpp
652
+ a_tran.find(ke)
653
+ ```
654
+
655
+ *Result:* `iterator`; `const_iterator` for constant `a_tran`.
656
+
657
+ *Returns:* An iterator pointing to an element with key `r` such that
658
+ `!c(r, ke) && !c(ke, r)` is `true`, or `a_tran.end()` if such an element
659
+ is not found.
660
+
661
+ *Complexity:* Logarithmic.
662
+
663
+ ``` cpp
664
+ b.count(k)
665
+ ```
666
+
667
+ *Result:* `size_type`
668
+
669
+ *Returns:* The number of elements with key equivalent to `k`.
670
+
671
+ *Complexity:* log (`b.size()`) + `b.count(k)`
672
+
673
+ ``` cpp
674
+ a_tran.count(ke)
675
+ ```
676
+
677
+ *Result:* `size_type`
678
+
679
+ *Returns:* The number of elements with key `r` such that
680
+ `!c(r, ke) && !c(ke, r)`.
681
+
682
+ *Complexity:* log (`a_tran.size()`) + `a_tran.count(ke)`
683
+
684
+ ``` cpp
685
+ b.contains(k)
686
+ ```
687
+
688
+ *Result:* `bool`
689
+
690
+ *Effects:* Equivalent to: `return b.find(k) != b.end();`
691
+
692
+ ``` cpp
693
+ a_tran.contains(ke)
694
+ ```
695
+
696
+ *Result:* `bool`
697
+
698
+ *Effects:* Equivalent to: `return a_tran.find(ke) != a_tran.end();`
699
+
700
+ ``` cpp
701
+ b.lower_bound(k)
702
+ ```
703
+
704
+ *Result:* `iterator`; `const_iterator` for constant `b`.
705
+
706
+ *Returns:* An iterator pointing to the first element with key not less
707
+ than `k`, or `b.end()` if such an element is not found.
708
+
709
+ *Complexity:* Logarithmic.
710
+
711
+ ``` cpp
712
+ a_tran.lower_bound(kl)
713
+ ```
714
+
715
+ *Result:* `iterator`; `const_iterator` for constant `a_tran`.
716
+
717
+ *Returns:* An iterator pointing to the first element with key `r` such
718
+ that `!c(r, kl)`, or `a_tran.end()` if such an element is not found.
719
+
720
+ *Complexity:* Logarithmic.
721
+
722
+ ``` cpp
723
+ b.upper_bound(k)
724
+ ```
725
+
726
+ *Result:* `iterator`; `const_iterator` for constant `b`.
727
+
728
+ *Returns:* An iterator pointing to the first element with key greater
729
+ than `k`, or `b.end()` if such an element is not found.
730
+
731
+ *Complexity:* Logarithmic,
732
+
733
+ ``` cpp
734
+ a_tran.upper_bound(ku)
735
+ ```
736
+
737
+ *Result:* `iterator`; `const_iterator` for constant `a_tran`.
738
+
739
+ *Returns:* An iterator pointing to the first element with key `r` such
740
+ that `c(ku, r)`, or `a_tran.end()` if such an element is not found.
741
+
742
+ *Complexity:* Logarithmic.
743
+
744
+ ``` cpp
745
+ b.equal_range(k)
746
+ ```
747
+
748
+ *Result:* `pair<iterator, iterator>`;
749
+ `pair<const_iterator, const_iterator>` for constant `b`.
750
+
751
+ *Effects:* Equivalent to:
752
+ `return make_pair(b.lower_bound(k), b.upper_bound(k));`
753
+
754
+ *Complexity:* Logarithmic.
755
+
756
+ ``` cpp
757
+ a_tran.equal_range(ke)
758
+ ```
759
+
760
+ *Result:* `pair<iterator, iterator>`;
761
+ `pair<const_iterator, const_iterator>` for constant `a_tran`.
762
+
763
+ *Effects:* Equivalent to:
764
+ `return make_pair(a_tran.lower_bound(ke), a_tran.upper_bound(ke));`
765
+
766
+ *Complexity:* Logarithmic.
767
+
768
+ The `insert`, `insert_range`, and `emplace` members shall not affect the
769
+ validity of iterators and references to the container, and the `erase`
770
+ members shall invalidate only iterators and references to the erased
771
+ elements.
772
 
773
  The `extract` members invalidate only iterators to the removed element;
774
  pointers and references to the removed element remain valid. However,
775
  accessing the element through such pointers and references while the
776
  element is owned by a `node_type` is undefined behavior. References and
 
802
  assignment operator, the target container shall then use the comparison
803
  object from the container being copied, as if that comparison object had
804
  been passed to the target container in its constructor.
805
 
806
  The member function templates `find`, `count`, `contains`,
807
+ `lower_bound`, `upper_bound`, `equal_range`, `erase`, and `extract`
808
+ shall not participate in overload resolution unless the *qualified-id*
809
+ `Compare::is_transparent` is valid and denotes a type [[temp.deduct]].
810
+ Additionally, the member function templates `extract` and `erase` shall
811
+ not participate in overload resolution if
812
+ `is_convertible_v<K&&, iterator> || is_convertible_v<K&&, const_iterator>`
813
+ is `true`, where `K` is the type substituted as the first template
814
+ argument.
815
 
816
  A deduction guide for an associative container shall not participate in
817
  overload resolution if any of the following are true:
818
 
819
  - It has an `InputIterator` template parameter and a type that does not