From Jason Turner

[map]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpm0251szm/{from.md → to.md} +192 -75
tmp/tmpm0251szm/{from.md → to.md} RENAMED
@@ -9,59 +9,57 @@ bidirectional iterators.
9
 
10
  A `map` satisfies all of the requirements of a container, of a
11
  reversible container ([[container.requirements]]), of an associative
12
  container ([[associative.reqmts]]), and of an allocator-aware container
13
  (Table  [[tab:containers.allocatoraware]]). A `map` also provides most
14
- operations described in ([[associative.reqmts]]) for unique keys. This
15
- means that a `map` supports the `a_uniq` operations in (
16
- [[associative.reqmts]]) but not the `a_eq` operations. For a
17
- `map<Key,T>` the `key_type` is `Key` and the `value_type` is
18
- `pair<const Key,T>`. Descriptions are provided here only for operations
19
- on `map` that are not described in one of those tables or for operations
20
- where there is additional semantic information.
21
 
22
  ``` cpp
23
  namespace std {
24
  template <class Key, class T, class Compare = less<Key>,
25
  class Allocator = allocator<pair<const Key, T>>>
26
  class map {
27
  public:
28
  // types:
29
- typedef Key key_type;
30
- typedef T mapped_type;
31
- typedef pair<const Key, T> value_type;
32
- typedef Compare key_compare;
33
- typedef Allocator allocator_type;
34
- typedef value_type& reference;
35
- typedef const value_type& const_reference;
36
- typedef implementation-defined iterator; // see [container.requirements]
37
- typedef implementation-defined const_iterator; // see [container.requirements]
38
- typedef implementation-defined size_type; // see [container.requirements]
39
- typedef implementation-defined difference_type;// see [container.requirements]
40
- typedef typename allocator_traits<Allocator>::pointer pointer;
41
- typedef typename allocator_traits<Allocator>::const_pointer const_pointer;
42
- typedef std::reverse_iterator<iterator> reverse_iterator;
43
- typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
 
 
44
 
45
  class value_compare {
46
  friend class map;
47
  protected:
48
  Compare comp;
49
  value_compare(Compare c) : comp(c) {}
50
  public:
51
- typedef bool result_type;
52
- typedef value_type first_argument_type;
53
- typedef value_type second_argument_type;
54
  bool operator()(const value_type& x, const value_type& y) const {
55
  return comp(x.first, y.first);
56
  }
57
  };
58
 
59
- // [map.cons], construct/copy/destroy:
60
  map() : map(Compare()) { }
61
- explicit map(const Compare& comp,
62
- const Allocator& = Allocator());
63
  template <class InputIterator>
64
  map(InputIterator first, InputIterator last,
65
  const Compare& comp = Compare(), const Allocator& = Allocator());
66
  map(const map& x);
67
  map(map&& x);
@@ -76,11 +74,13 @@ namespace std {
76
  : map(first, last, Compare(), a) { }
77
  map(initializer_list<value_type> il, const Allocator& a)
78
  : map(il, Compare(), a) { }
79
  ~map();
80
  map& operator=(const map& x);
81
- map& operator=(map&& x);
 
 
82
  map& operator=(initializer_list<value_type>);
83
  allocator_type get_allocator() const noexcept;
84
 
85
  // iterators:
86
  iterator begin() noexcept;
@@ -101,34 +101,70 @@ namespace std {
101
  // capacity:
102
  bool empty() const noexcept;
103
  size_type size() const noexcept;
104
  size_type max_size() const noexcept;
105
 
106
- // [map.access], element access:
107
  T& operator[](const key_type& x);
108
  T& operator[](key_type&& x);
109
  T& at(const key_type& x);
110
  const T& at(const key_type& x) const;
111
 
112
- // [map.modifiers], modifiers:
113
  template <class... Args> pair<iterator, bool> emplace(Args&&... args);
114
  template <class... Args> iterator emplace_hint(const_iterator position, Args&&... args);
115
  pair<iterator, bool> insert(const value_type& x);
 
116
  template <class P> pair<iterator, bool> insert(P&& x);
117
  iterator insert(const_iterator position, const value_type& x);
 
118
  template <class P>
119
  iterator insert(const_iterator position, P&&);
120
  template <class InputIterator>
121
  void insert(InputIterator first, InputIterator last);
122
  void insert(initializer_list<value_type>);
123
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
124
  iterator erase(const_iterator position);
125
  size_type erase(const key_type& x);
126
  iterator erase(const_iterator first, const_iterator last);
127
- void swap(map&);
 
 
128
  void clear() noexcept;
129
 
 
 
 
 
 
 
 
 
 
130
  // observers:
131
  key_compare key_comp() const;
132
  value_compare value_comp() const;
133
 
134
  // map operations:
@@ -148,20 +184,36 @@ namespace std {
148
  iterator upper_bound(const key_type& x);
149
  const_iterator upper_bound(const key_type& x) const;
150
  template <class K> iterator upper_bound(const K& x);
151
  template <class K> const_iterator upper_bound(const K& x) const;
152
 
153
- pair<iterator,iterator>
154
- equal_range(const key_type& x);
155
- pair<const_iterator,const_iterator>
156
- equal_range(const key_type& x) const;
157
  template <class K>
158
  pair<iterator, iterator> equal_range(const K& x);
159
  template <class K>
160
  pair<const_iterator, const_iterator> equal_range(const K& x) const;
161
  };
162
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
163
  template <class Key, class T, class Compare, class Allocator>
164
  bool operator==(const map<Key, T, Compare, Allocator>& x,
165
  const map<Key, T, Compare, Allocator>& y);
166
  template <class Key, class T, class Compare, class Allocator>
167
  bool operator< (const map<Key, T, Compare, Allocator>& x,
@@ -177,22 +229,22 @@ namespace std {
177
  const map<Key, T, Compare, Allocator>& y);
178
  template <class Key, class T, class Compare, class Allocator>
179
  bool operator<=(const map<Key, T, Compare, Allocator>& x,
180
  const map<Key, T, Compare, Allocator>& y);
181
 
182
- // specialized algorithms:
183
  template <class Key, class T, class Compare, class Allocator>
184
  void swap(map<Key, T, Compare, Allocator>& x,
185
- map<Key,T,Compare,Allocator>& y);
 
186
  }
187
  ```
188
 
189
  #### `map` constructors, copy, and assignment <a id="map.cons">[[map.cons]]</a>
190
 
191
  ``` cpp
192
- explicit map(const Compare& comp,
193
- const Allocator& = Allocator());
194
  ```
195
 
196
  *Effects:* Constructs an empty `map` using the specified comparison
197
  object and allocator.
198
 
@@ -202,51 +254,30 @@ object and allocator.
202
  template <class InputIterator>
203
  map(InputIterator first, InputIterator last,
204
  const Compare& comp = Compare(), const Allocator& = Allocator());
205
  ```
206
 
207
- *Requires:* If the iterator’s indirection operator returns an lvalue or
208
- a const rvalue `pair<key_type, mapped_type>`, then both `key_type` and
209
- `mapped_type` shall be `CopyInsertable` into `*this`.
210
-
211
  *Effects:* Constructs an empty `map` using the specified comparison
212
  object and allocator, and inserts elements from the range \[`first`,
213
  `last`).
214
 
215
  *Complexity:* Linear in N if the range \[`first`, `last`) is already
216
- sorted using `comp` and otherwise N log N, where N is `last` - `first`.
217
 
218
  #### `map` element access <a id="map.access">[[map.access]]</a>
219
 
220
  ``` cpp
221
  T& operator[](const key_type& x);
222
  ```
223
 
224
- *Effects:* If there is no key equivalent to `x` in the map, inserts
225
- `value_type(x, T())` into the map.
226
-
227
- *Requires:* `key_type` shall be `CopyInsertable` and `mapped_type` shall
228
- be `DefaultInsertable` into `*this`.
229
-
230
- *Returns:* A reference to the `mapped_type` corresponding to `x` in
231
- `*this`.
232
-
233
- *Complexity:* Logarithmic.
234
 
235
  ``` cpp
236
  T& operator[](key_type&& x);
237
  ```
238
 
239
- *Effects:* If there is no key equivalent to `x` in the map, inserts
240
- `value_type(std::move(x), T())` into the map.
241
-
242
- *Requires:* `mapped_type` shall be `DefaultInsertable` into `*this`.
243
-
244
- *Returns:* A reference to the `mapped_type` corresponding to `x` in
245
- `*this`.
246
-
247
- *Complexity:* Logarithmic.
248
 
249
  ``` cpp
250
  T& at(const key_type& x);
251
  const T& at(const key_type& x) const;
252
  ```
@@ -260,32 +291,118 @@ is present.
260
  *Complexity:* Logarithmic.
261
 
262
  #### `map` modifiers <a id="map.modifiers">[[map.modifiers]]</a>
263
 
264
  ``` cpp
265
- template <class P> pair<iterator, bool> insert(P&& x);
266
- template <class P> iterator insert(const_iterator position, P&& x);
267
- template <class InputIterator>
268
- void insert(InputIterator first, InputIterator last);
269
  ```
270
 
271
  *Effects:* The first form is equivalent to
272
  `return emplace(std::forward<P>(x))`. The second form is equivalent to
273
  `return emplace_hint(position, std::forward<P>(x))`.
274
 
275
  *Remarks:* These signatures shall not participate in overload resolution
276
- unless `std::is_constructible<value_type, P&&>::value` is `true`.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
277
 
278
  #### `map` specialized algorithms <a id="map.special">[[map.special]]</a>
279
 
280
  ``` cpp
281
  template <class Key, class T, class Compare, class Allocator>
282
  void swap(map<Key, T, Compare, Allocator>& x,
283
- map<Key,T,Compare,Allocator>& y);
 
284
  ```
285
 
286
- *Effects:*
287
-
288
- ``` cpp
289
- x.swap(y);
290
- ```
291
 
 
9
 
10
  A `map` satisfies all of the requirements of a container, of a
11
  reversible container ([[container.requirements]]), of an associative
12
  container ([[associative.reqmts]]), and of an allocator-aware container
13
  (Table  [[tab:containers.allocatoraware]]). A `map` also provides most
14
+ operations described in  [[associative.reqmts]] for unique keys. This
15
+ means that a `map` supports the `a_uniq` operations in 
16
+ [[associative.reqmts]] but not the `a_eq` operations. For a `map<Key,T>`
17
+ the `key_type` is `Key` and the `value_type` is `pair<const Key,T>`.
18
+ Descriptions are provided here only for operations on `map` that are not
19
+ described in one of those tables or for operations where there is
20
+ additional semantic information.
21
 
22
  ``` cpp
23
  namespace std {
24
  template <class Key, class T, class Compare = less<Key>,
25
  class Allocator = allocator<pair<const Key, T>>>
26
  class map {
27
  public:
28
  // types:
29
+ using key_type = Key;
30
+ using mapped_type = T;
31
+ using value_type = pair<const Key, T>;
32
+ using key_compare = Compare;
33
+ using allocator_type = Allocator;
34
+ using pointer = typename allocator_traits<Allocator>::pointer;
35
+ using const_pointer = typename allocator_traits<Allocator>::const_pointer;
36
+ using reference = value_type&;
37
+ using const_reference = const value_type&;
38
+ using size_type = implementation-defined; // see [container.requirements]
39
+ using difference_type = implementation-defined; // see [container.requirements]
40
+ using iterator = implementation-defined // type of map::iterator; // see [container.requirements]
41
+ using const_iterator = implementation-defined // type of map::const_iterator; // see [container.requirements]
42
+ using reverse_iterator = std::reverse_iterator<iterator>;
43
+ using const_reverse_iterator = std::reverse_iterator<const_iterator>;
44
+ using node_type = unspecified;
45
+ using insert_return_type = INSERT_RETURN_TYPE<iterator, node_type>;
46
 
47
  class value_compare {
48
  friend class map;
49
  protected:
50
  Compare comp;
51
  value_compare(Compare c) : comp(c) {}
52
  public:
 
 
 
53
  bool operator()(const value_type& x, const value_type& y) const {
54
  return comp(x.first, y.first);
55
  }
56
  };
57
 
58
+ // [map.cons], construct/copy/destroy
59
  map() : map(Compare()) { }
60
+ explicit map(const Compare& comp, const Allocator& = Allocator());
 
61
  template <class InputIterator>
62
  map(InputIterator first, InputIterator last,
63
  const Compare& comp = Compare(), const Allocator& = Allocator());
64
  map(const map& x);
65
  map(map&& x);
 
74
  : map(first, last, Compare(), a) { }
75
  map(initializer_list<value_type> il, const Allocator& a)
76
  : map(il, Compare(), a) { }
77
  ~map();
78
  map& operator=(const map& x);
79
+ map& operator=(map&& x)
80
+ noexcept(allocator_traits<Allocator>::is_always_equal::value &&
81
+ is_nothrow_move_assignable_v<Compare>);
82
  map& operator=(initializer_list<value_type>);
83
  allocator_type get_allocator() const noexcept;
84
 
85
  // iterators:
86
  iterator begin() noexcept;
 
101
  // capacity:
102
  bool empty() const noexcept;
103
  size_type size() const noexcept;
104
  size_type max_size() const noexcept;
105
 
106
+ // [map.access], element access
107
  T& operator[](const key_type& x);
108
  T& operator[](key_type&& x);
109
  T& at(const key_type& x);
110
  const T& at(const key_type& x) const;
111
 
112
+ // [map.modifiers], modifiers
113
  template <class... Args> pair<iterator, bool> emplace(Args&&... args);
114
  template <class... Args> iterator emplace_hint(const_iterator position, Args&&... args);
115
  pair<iterator, bool> insert(const value_type& x);
116
+ pair<iterator, bool> insert(value_type&& x);
117
  template <class P> pair<iterator, bool> insert(P&& x);
118
  iterator insert(const_iterator position, const value_type& x);
119
+ iterator insert(const_iterator position, value_type&& x);
120
  template <class P>
121
  iterator insert(const_iterator position, P&&);
122
  template <class InputIterator>
123
  void insert(InputIterator first, InputIterator last);
124
  void insert(initializer_list<value_type>);
125
 
126
+ node_type extract(const_iterator position);
127
+ node_type extract(const key_type& x);
128
+ insert_return_type insert(node_type&& nh);
129
+ iterator insert(const_iterator hint, node_type&& nh);
130
+
131
+ template <class... Args>
132
+ pair<iterator, bool> try_emplace(const key_type& k, Args&&... args);
133
+ template <class... Args>
134
+ pair<iterator, bool> try_emplace(key_type&& k, Args&&... args);
135
+ template <class... Args>
136
+ iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args);
137
+ template <class... Args>
138
+ iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args);
139
+ template <class M>
140
+ pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj);
141
+ template <class M>
142
+ pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj);
143
+ template <class M>
144
+ iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj);
145
+ template <class M>
146
+ iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj);
147
+
148
+ iterator erase(iterator position);
149
  iterator erase(const_iterator position);
150
  size_type erase(const key_type& x);
151
  iterator erase(const_iterator first, const_iterator last);
152
+ void swap(map&)
153
+ noexcept(allocator_traits<Allocator>::is_always_equal::value &&
154
+ is_nothrow_swappable_v<Compare>);
155
  void clear() noexcept;
156
 
157
+ template<class C2>
158
+ void merge(map<Key, T, C2, Allocator>& source);
159
+ template<class C2>
160
+ void merge(map<Key, T, C2, Allocator>&& source);
161
+ template<class C2>
162
+ void merge(multimap<Key, T, C2, Allocator>& source);
163
+ template<class C2>
164
+ void merge(multimap<Key, T, C2, Allocator>&& source);
165
+
166
  // observers:
167
  key_compare key_comp() const;
168
  value_compare value_comp() const;
169
 
170
  // map operations:
 
184
  iterator upper_bound(const key_type& x);
185
  const_iterator upper_bound(const key_type& x) const;
186
  template <class K> iterator upper_bound(const K& x);
187
  template <class K> const_iterator upper_bound(const K& x) const;
188
 
189
+ pair<iterator, iterator> equal_range(const key_type& x);
190
+ pair<const_iterator, const_iterator> equal_range(const key_type& x) const;
 
 
191
  template <class K>
192
  pair<iterator, iterator> equal_range(const K& x);
193
  template <class K>
194
  pair<const_iterator, const_iterator> equal_range(const K& x) const;
195
  };
196
 
197
+ template<class InputIterator, class Compare = less<iter_key_t<InputIterator>>,
198
+ class Allocator = allocator<iter_to_alloc_t<InputIterator>>>
199
+ map(InputIterator, InputIterator, Compare = Compare(), Allocator = Allocator())
200
+ -> map<iter_key_t<InputIterator>, iter_val_t<InputIterator>, Compare, Allocator>;
201
+
202
+ template<class Key, class T, class Compare = less<Key>,
203
+ class Allocator = allocator<pair<const Key, T>>>
204
+ map(initializer_list<pair<const Key, T>>, Compare = Compare(), Allocator = Allocator())
205
+ -> map<Key, T, Compare, Allocator>;
206
+
207
+ template <class InputIterator, class Allocator>
208
+ map(InputIterator, InputIterator, Allocator)
209
+ -> map<iter_key_t<InputIterator>, iter_val_t<InputIterator>,
210
+ less<iter_key_t<InputIterator>>, Allocator>;
211
+
212
+ template<class Key, class T, class Allocator>
213
+ map(initializer_list<pair<const Key, T>>, Allocator) -> map<Key, T, less<Key>, Allocator>;
214
+
215
  template <class Key, class T, class Compare, class Allocator>
216
  bool operator==(const map<Key, T, Compare, Allocator>& x,
217
  const map<Key, T, Compare, Allocator>& y);
218
  template <class Key, class T, class Compare, class Allocator>
219
  bool operator< (const map<Key, T, Compare, Allocator>& x,
 
229
  const map<Key, T, Compare, Allocator>& y);
230
  template <class Key, class T, class Compare, class Allocator>
231
  bool operator<=(const map<Key, T, Compare, Allocator>& x,
232
  const map<Key, T, Compare, Allocator>& y);
233
 
234
+ // [map.special], specialized algorithms
235
  template <class Key, class T, class Compare, class Allocator>
236
  void swap(map<Key, T, Compare, Allocator>& x,
237
+ map<Key, T, Compare, Allocator>& y)
238
+ noexcept(noexcept(x.swap(y)));
239
  }
240
  ```
241
 
242
  #### `map` constructors, copy, and assignment <a id="map.cons">[[map.cons]]</a>
243
 
244
  ``` cpp
245
+ explicit map(const Compare& comp, const Allocator& = Allocator());
 
246
  ```
247
 
248
  *Effects:* Constructs an empty `map` using the specified comparison
249
  object and allocator.
250
 
 
254
  template <class InputIterator>
255
  map(InputIterator first, InputIterator last,
256
  const Compare& comp = Compare(), const Allocator& = Allocator());
257
  ```
258
 
 
 
 
 
259
  *Effects:* Constructs an empty `map` using the specified comparison
260
  object and allocator, and inserts elements from the range \[`first`,
261
  `last`).
262
 
263
  *Complexity:* Linear in N if the range \[`first`, `last`) is already
264
+ sorted using `comp` and otherwise N log N, where N is `last - first`.
265
 
266
  #### `map` element access <a id="map.access">[[map.access]]</a>
267
 
268
  ``` cpp
269
  T& operator[](const key_type& x);
270
  ```
271
 
272
+ *Effects:* Equivalent to: `return try_emplace(x).first->second;`
 
 
 
 
 
 
 
 
 
273
 
274
  ``` cpp
275
  T& operator[](key_type&& x);
276
  ```
277
 
278
+ *Effects:* Equivalent to: `return try_emplace(move(x)).first->second;`
 
 
 
 
 
 
 
 
279
 
280
  ``` cpp
281
  T& at(const key_type& x);
282
  const T& at(const key_type& x) const;
283
  ```
 
291
  *Complexity:* Logarithmic.
292
 
293
  #### `map` modifiers <a id="map.modifiers">[[map.modifiers]]</a>
294
 
295
  ``` cpp
296
+ template <class P>
297
+ pair<iterator, bool> insert(P&& x);
298
+ template <class P>
299
+ iterator insert(const_iterator position, P&& x);
300
  ```
301
 
302
  *Effects:* The first form is equivalent to
303
  `return emplace(std::forward<P>(x))`. The second form is equivalent to
304
  `return emplace_hint(position, std::forward<P>(x))`.
305
 
306
  *Remarks:* These signatures shall not participate in overload resolution
307
+ unless `is_constructible_v<value_type, P&&>` is `true`.
308
+
309
+ ``` cpp
310
+ template <class... Args>
311
+ pair<iterator, bool> try_emplace(const key_type& k, Args&&... args);
312
+ template <class... Args>
313
+ iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args);
314
+ ```
315
+
316
+ *Requires:* `value_type` shall be `EmplaceConstructible` into `map` from
317
+ `piecewise_construct`, `forward_as_tuple(k)`,
318
+ `forward_as_tuple(std::forward<Args>(args)...)`.
319
+
320
+ *Effects:* If the map already contains an element whose key is
321
+ equivalent to `k`, there is no effect. Otherwise inserts an object of
322
+ type `value_type` constructed with `piecewise_construct`,
323
+ `forward_as_tuple(k)`, `forward_as_tuple(std::forward<Args>(args)...)`.
324
+
325
+ *Returns:* In the first overload, the `bool` component of the returned
326
+ pair is `true` if and only if the insertion took place. The returned
327
+ iterator points to the map element whose key is equivalent to `k`.
328
+
329
+ *Complexity:* The same as `emplace` and `emplace_hint`, respectively.
330
+
331
+ ``` cpp
332
+ template <class... Args>
333
+ pair<iterator, bool> try_emplace(key_type&& k, Args&&... args);
334
+ template <class... Args>
335
+ iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args);
336
+ ```
337
+
338
+ *Requires:* `value_type` shall be `EmplaceConstructible` into `map` from
339
+ `piecewise_construct`, `forward_as_tuple(std::move(k))`,
340
+ `forward_as_tuple(std::forward<Args>(args)...)`.
341
+
342
+ *Effects:* If the map already contains an element whose key is
343
+ equivalent to `k`, there is no effect. Otherwise inserts an object of
344
+ type `value_type` constructed with `piecewise_construct`,
345
+ `forward_as_tuple(std::move(k))`,
346
+ `forward_as_tuple(std::forward<Args>(args)...)`.
347
+
348
+ *Returns:* In the first overload, the `bool` component of the returned
349
+ pair is `true` if and only if the insertion took place. The returned
350
+ iterator points to the map element whose key is equivalent to `k`.
351
+
352
+ *Complexity:* The same as `emplace` and `emplace_hint`, respectively.
353
+
354
+ ``` cpp
355
+ template <class M>
356
+ pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj);
357
+ template <class M>
358
+ iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj);
359
+ ```
360
+
361
+ *Requires:* `is_assignable_v<mapped_type&, M&&>` shall be `true`.
362
+ `value_type` shall be `EmplaceConstructible` into `map` from `k`,
363
+ `forward<M>(obj)`.
364
+
365
+ *Effects:* If the map already contains an element `e` whose key is
366
+ equivalent to `k`, assigns `std::forward<M>(obj)` to `e.second`.
367
+ Otherwise inserts an object of type `value_type` constructed with `k`,
368
+ `std::forward<M>(obj)`.
369
+
370
+ *Returns:* In the first overload, the `bool` component of the returned
371
+ pair is `true` if and only if the insertion took place. The returned
372
+ iterator points to the map element whose key is equivalent to `k`.
373
+
374
+ *Complexity:* The same as `emplace` and `emplace_hint`, respectively.
375
+
376
+ ``` cpp
377
+ template <class M>
378
+ pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj);
379
+ template <class M>
380
+ iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj);
381
+ ```
382
+
383
+ *Requires:* `is_assignable_v<mapped_type&, M&&>` shall be `true`.
384
+ `value_type` shall be `EmplaceConstructible` into `map` from `move(k)`,
385
+ `forward<M>(obj)`.
386
+
387
+ *Effects:* If the map already contains an element `e` whose key is
388
+ equivalent to `k`, assigns `std::forward<M>(obj)` to `e.second`.
389
+ Otherwise inserts an object of type `value_type` constructed with
390
+ `std::move(k)`, `std::forward<M>(obj)`.
391
+
392
+ *Returns:* In the first overload, the `bool` component of the returned
393
+ pair is `true` if and only if the insertion took place. The returned
394
+ iterator points to the map element whose key is equivalent to `k`.
395
+
396
+ *Complexity:* The same as `emplace` and `emplace_hint`, respectively.
397
 
398
  #### `map` specialized algorithms <a id="map.special">[[map.special]]</a>
399
 
400
  ``` cpp
401
  template <class Key, class T, class Compare, class Allocator>
402
  void swap(map<Key, T, Compare, Allocator>& x,
403
+ map<Key, T, Compare, Allocator>& y)
404
+ noexcept(noexcept(x.swap(y)));
405
  ```
406
 
407
+ *Effects:* As if by `x.swap(y)`.
 
 
 
 
408