- tmp/tmp8jlnrd3h/{from.md → to.md} +457 -208
tmp/tmp8jlnrd3h/{from.md → to.md}
RENAMED
|
@@ -3,17 +3,33 @@
|
|
| 3 |
### In general <a id="associative.general">[[associative.general]]</a>
|
| 4 |
|
| 5 |
The header `<map>` defines the class templates `map` and `multimap`; the
|
| 6 |
header `<set>` defines the class templates `set` and `multiset`.
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
### Header `<map>` synopsis <a id="associative.map.syn">[[associative.map.syn]]</a>
|
| 9 |
|
| 10 |
``` cpp
|
| 11 |
#include <initializer_list>
|
| 12 |
|
| 13 |
namespace std {
|
| 14 |
-
|
| 15 |
template <class Key, class T, class Compare = less<Key>,
|
| 16 |
class Allocator = allocator<pair<const Key, T>>>
|
| 17 |
class map;
|
| 18 |
template <class Key, class T, class Compare, class Allocator>
|
| 19 |
bool operator==(const map<Key, T, Compare, Allocator>& x,
|
|
@@ -33,12 +49,14 @@ namespace std {
|
|
| 33 |
template <class Key, class T, class Compare, class Allocator>
|
| 34 |
bool operator<=(const map<Key, T, Compare, Allocator>& x,
|
| 35 |
const map<Key, T, Compare, Allocator>& y);
|
| 36 |
template <class Key, class T, class Compare, class Allocator>
|
| 37 |
void swap(map<Key, T, Compare, Allocator>& x,
|
| 38 |
-
map<Key,T,Compare,Allocator>& y)
|
|
|
|
| 39 |
|
|
|
|
| 40 |
template <class Key, class T, class Compare = less<Key>,
|
| 41 |
class Allocator = allocator<pair<const Key, T>>>
|
| 42 |
class multimap;
|
| 43 |
template <class Key, class T, class Compare, class Allocator>
|
| 44 |
bool operator==(const multimap<Key, T, Compare, Allocator>& x,
|
|
@@ -58,21 +76,32 @@ namespace std {
|
|
| 58 |
template <class Key, class T, class Compare, class Allocator>
|
| 59 |
bool operator<=(const multimap<Key, T, Compare, Allocator>& x,
|
| 60 |
const multimap<Key, T, Compare, Allocator>& y);
|
| 61 |
template <class Key, class T, class Compare, class Allocator>
|
| 62 |
void swap(multimap<Key, T, Compare, Allocator>& x,
|
| 63 |
-
multimap<Key,T,Compare,Allocator>& y)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
}
|
| 65 |
```
|
| 66 |
|
| 67 |
### Header `<set>` synopsis <a id="associative.set.syn">[[associative.set.syn]]</a>
|
| 68 |
|
| 69 |
``` cpp
|
| 70 |
#include <initializer_list>
|
| 71 |
|
| 72 |
namespace std {
|
| 73 |
-
|
| 74 |
template <class Key, class Compare = less<Key>,
|
| 75 |
class Allocator = allocator<Key>>
|
| 76 |
class set;
|
| 77 |
template <class Key, class Compare, class Allocator>
|
| 78 |
bool operator==(const set<Key, Compare, Allocator>& x,
|
|
@@ -92,12 +121,14 @@ namespace std {
|
|
| 92 |
template <class Key, class Compare, class Allocator>
|
| 93 |
bool operator<=(const set<Key, Compare, Allocator>& x,
|
| 94 |
const set<Key, Compare, Allocator>& y);
|
| 95 |
template <class Key, class Compare, class Allocator>
|
| 96 |
void swap(set<Key, Compare, Allocator>& x,
|
| 97 |
-
set<Key,Compare,Allocator>& y)
|
|
|
|
| 98 |
|
|
|
|
| 99 |
template <class Key, class Compare = less<Key>,
|
| 100 |
class Allocator = allocator<Key>>
|
| 101 |
class multiset;
|
| 102 |
template <class Key, class Compare, class Allocator>
|
| 103 |
bool operator==(const multiset<Key, Compare, Allocator>& x,
|
|
@@ -117,11 +148,22 @@ namespace std {
|
|
| 117 |
template <class Key, class Compare, class Allocator>
|
| 118 |
bool operator<=(const multiset<Key, Compare, Allocator>& x,
|
| 119 |
const multiset<Key, Compare, Allocator>& y);
|
| 120 |
template <class Key, class Compare, class Allocator>
|
| 121 |
void swap(multiset<Key, Compare, Allocator>& x,
|
| 122 |
-
multiset<Key,Compare,Allocator>& y)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
}
|
| 124 |
```
|
| 125 |
|
| 126 |
### Class template `map` <a id="map">[[map]]</a>
|
| 127 |
|
|
@@ -134,59 +176,57 @@ bidirectional iterators.
|
|
| 134 |
|
| 135 |
A `map` satisfies all of the requirements of a container, of a
|
| 136 |
reversible container ([[container.requirements]]), of an associative
|
| 137 |
container ([[associative.reqmts]]), and of an allocator-aware container
|
| 138 |
(Table [[tab:containers.allocatoraware]]). A `map` also provides most
|
| 139 |
-
operations described in
|
| 140 |
-
means that a `map` supports the `a_uniq` operations in
|
| 141 |
-
[[associative.reqmts]]
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
|
| 147 |
``` cpp
|
| 148 |
namespace std {
|
| 149 |
template <class Key, class T, class Compare = less<Key>,
|
| 150 |
class Allocator = allocator<pair<const Key, T>>>
|
| 151 |
class map {
|
| 152 |
public:
|
| 153 |
// types:
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
|
|
|
|
|
|
| 169 |
|
| 170 |
class value_compare {
|
| 171 |
friend class map;
|
| 172 |
protected:
|
| 173 |
Compare comp;
|
| 174 |
value_compare(Compare c) : comp(c) {}
|
| 175 |
public:
|
| 176 |
-
typedef bool result_type;
|
| 177 |
-
typedef value_type first_argument_type;
|
| 178 |
-
typedef value_type second_argument_type;
|
| 179 |
bool operator()(const value_type& x, const value_type& y) const {
|
| 180 |
return comp(x.first, y.first);
|
| 181 |
}
|
| 182 |
};
|
| 183 |
|
| 184 |
-
// [map.cons], construct/copy/destroy
|
| 185 |
map() : map(Compare()) { }
|
| 186 |
-
explicit map(const Compare& comp,
|
| 187 |
-
const Allocator& = Allocator());
|
| 188 |
template <class InputIterator>
|
| 189 |
map(InputIterator first, InputIterator last,
|
| 190 |
const Compare& comp = Compare(), const Allocator& = Allocator());
|
| 191 |
map(const map& x);
|
| 192 |
map(map&& x);
|
|
@@ -201,11 +241,13 @@ namespace std {
|
|
| 201 |
: map(first, last, Compare(), a) { }
|
| 202 |
map(initializer_list<value_type> il, const Allocator& a)
|
| 203 |
: map(il, Compare(), a) { }
|
| 204 |
~map();
|
| 205 |
map& operator=(const map& x);
|
| 206 |
-
map& operator=(map&& x)
|
|
|
|
|
|
|
| 207 |
map& operator=(initializer_list<value_type>);
|
| 208 |
allocator_type get_allocator() const noexcept;
|
| 209 |
|
| 210 |
// iterators:
|
| 211 |
iterator begin() noexcept;
|
|
@@ -226,34 +268,70 @@ namespace std {
|
|
| 226 |
// capacity:
|
| 227 |
bool empty() const noexcept;
|
| 228 |
size_type size() const noexcept;
|
| 229 |
size_type max_size() const noexcept;
|
| 230 |
|
| 231 |
-
// [map.access], element access
|
| 232 |
T& operator[](const key_type& x);
|
| 233 |
T& operator[](key_type&& x);
|
| 234 |
T& at(const key_type& x);
|
| 235 |
const T& at(const key_type& x) const;
|
| 236 |
|
| 237 |
-
// [map.modifiers], modifiers
|
| 238 |
template <class... Args> pair<iterator, bool> emplace(Args&&... args);
|
| 239 |
template <class... Args> iterator emplace_hint(const_iterator position, Args&&... args);
|
| 240 |
pair<iterator, bool> insert(const value_type& x);
|
|
|
|
| 241 |
template <class P> pair<iterator, bool> insert(P&& x);
|
| 242 |
iterator insert(const_iterator position, const value_type& x);
|
|
|
|
| 243 |
template <class P>
|
| 244 |
iterator insert(const_iterator position, P&&);
|
| 245 |
template <class InputIterator>
|
| 246 |
void insert(InputIterator first, InputIterator last);
|
| 247 |
void insert(initializer_list<value_type>);
|
| 248 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 249 |
iterator erase(const_iterator position);
|
| 250 |
size_type erase(const key_type& x);
|
| 251 |
iterator erase(const_iterator first, const_iterator last);
|
| 252 |
-
void
|
|
|
|
|
|
|
| 253 |
void clear() noexcept;
|
| 254 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 255 |
// observers:
|
| 256 |
key_compare key_comp() const;
|
| 257 |
value_compare value_comp() const;
|
| 258 |
|
| 259 |
// map operations:
|
|
@@ -273,20 +351,36 @@ namespace std {
|
|
| 273 |
iterator upper_bound(const key_type& x);
|
| 274 |
const_iterator upper_bound(const key_type& x) const;
|
| 275 |
template <class K> iterator upper_bound(const K& x);
|
| 276 |
template <class K> const_iterator upper_bound(const K& x) const;
|
| 277 |
|
| 278 |
-
pair<iterator,iterator>
|
| 279 |
-
|
| 280 |
-
pair<const_iterator,const_iterator>
|
| 281 |
-
equal_range(const key_type& x) const;
|
| 282 |
template <class K>
|
| 283 |
pair<iterator, iterator> equal_range(const K& x);
|
| 284 |
template <class K>
|
| 285 |
pair<const_iterator, const_iterator> equal_range(const K& x) const;
|
| 286 |
};
|
| 287 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 288 |
template <class Key, class T, class Compare, class Allocator>
|
| 289 |
bool operator==(const map<Key, T, Compare, Allocator>& x,
|
| 290 |
const map<Key, T, Compare, Allocator>& y);
|
| 291 |
template <class Key, class T, class Compare, class Allocator>
|
| 292 |
bool operator< (const map<Key, T, Compare, Allocator>& x,
|
|
@@ -302,22 +396,22 @@ namespace std {
|
|
| 302 |
const map<Key, T, Compare, Allocator>& y);
|
| 303 |
template <class Key, class T, class Compare, class Allocator>
|
| 304 |
bool operator<=(const map<Key, T, Compare, Allocator>& x,
|
| 305 |
const map<Key, T, Compare, Allocator>& y);
|
| 306 |
|
| 307 |
-
// specialized algorithms
|
| 308 |
template <class Key, class T, class Compare, class Allocator>
|
| 309 |
void swap(map<Key, T, Compare, Allocator>& x,
|
| 310 |
-
map<Key,T,Compare,Allocator>& y)
|
|
|
|
| 311 |
}
|
| 312 |
```
|
| 313 |
|
| 314 |
#### `map` constructors, copy, and assignment <a id="map.cons">[[map.cons]]</a>
|
| 315 |
|
| 316 |
``` cpp
|
| 317 |
-
explicit map(const Compare& comp,
|
| 318 |
-
const Allocator& = Allocator());
|
| 319 |
```
|
| 320 |
|
| 321 |
*Effects:* Constructs an empty `map` using the specified comparison
|
| 322 |
object and allocator.
|
| 323 |
|
|
@@ -327,51 +421,30 @@ object and allocator.
|
|
| 327 |
template <class InputIterator>
|
| 328 |
map(InputIterator first, InputIterator last,
|
| 329 |
const Compare& comp = Compare(), const Allocator& = Allocator());
|
| 330 |
```
|
| 331 |
|
| 332 |
-
*Requires:* If the iterator’s indirection operator returns an lvalue or
|
| 333 |
-
a const rvalue `pair<key_type, mapped_type>`, then both `key_type` and
|
| 334 |
-
`mapped_type` shall be `CopyInsertable` into `*this`.
|
| 335 |
-
|
| 336 |
*Effects:* Constructs an empty `map` using the specified comparison
|
| 337 |
object and allocator, and inserts elements from the range \[`first`,
|
| 338 |
`last`).
|
| 339 |
|
| 340 |
*Complexity:* Linear in N if the range \[`first`, `last`) is already
|
| 341 |
-
sorted using `comp` and otherwise N log N, where N is `last
|
| 342 |
|
| 343 |
#### `map` element access <a id="map.access">[[map.access]]</a>
|
| 344 |
|
| 345 |
``` cpp
|
| 346 |
T& operator[](const key_type& x);
|
| 347 |
```
|
| 348 |
|
| 349 |
-
*Effects:*
|
| 350 |
-
`value_type(x, T())` into the map.
|
| 351 |
-
|
| 352 |
-
*Requires:* `key_type` shall be `CopyInsertable` and `mapped_type` shall
|
| 353 |
-
be `DefaultInsertable` into `*this`.
|
| 354 |
-
|
| 355 |
-
*Returns:* A reference to the `mapped_type` corresponding to `x` in
|
| 356 |
-
`*this`.
|
| 357 |
-
|
| 358 |
-
*Complexity:* Logarithmic.
|
| 359 |
|
| 360 |
``` cpp
|
| 361 |
T& operator[](key_type&& x);
|
| 362 |
```
|
| 363 |
|
| 364 |
-
*Effects:*
|
| 365 |
-
`value_type(std::move(x), T())` into the map.
|
| 366 |
-
|
| 367 |
-
*Requires:* `mapped_type` shall be `DefaultInsertable` into `*this`.
|
| 368 |
-
|
| 369 |
-
*Returns:* A reference to the `mapped_type` corresponding to `x` in
|
| 370 |
-
`*this`.
|
| 371 |
-
|
| 372 |
-
*Complexity:* Logarithmic.
|
| 373 |
|
| 374 |
``` cpp
|
| 375 |
T& at(const key_type& x);
|
| 376 |
const T& at(const key_type& x) const;
|
| 377 |
```
|
|
@@ -385,36 +458,122 @@ is present.
|
|
| 385 |
*Complexity:* Logarithmic.
|
| 386 |
|
| 387 |
#### `map` modifiers <a id="map.modifiers">[[map.modifiers]]</a>
|
| 388 |
|
| 389 |
``` cpp
|
| 390 |
-
template <class P>
|
| 391 |
-
|
| 392 |
-
template <class
|
| 393 |
-
|
| 394 |
```
|
| 395 |
|
| 396 |
*Effects:* The first form is equivalent to
|
| 397 |
`return emplace(std::forward<P>(x))`. The second form is equivalent to
|
| 398 |
`return emplace_hint(position, std::forward<P>(x))`.
|
| 399 |
|
| 400 |
*Remarks:* These signatures shall not participate in overload resolution
|
| 401 |
-
unless `
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 402 |
|
| 403 |
#### `map` specialized algorithms <a id="map.special">[[map.special]]</a>
|
| 404 |
|
| 405 |
``` cpp
|
| 406 |
template <class Key, class T, class Compare, class Allocator>
|
| 407 |
void swap(map<Key, T, Compare, Allocator>& x,
|
| 408 |
-
map<Key,T,Compare,Allocator>& y)
|
|
|
|
| 409 |
```
|
| 410 |
|
| 411 |
-
*Effects:*
|
| 412 |
-
|
| 413 |
-
``` cpp
|
| 414 |
-
x.swap(y);
|
| 415 |
-
```
|
| 416 |
|
| 417 |
### Class template `multimap` <a id="multimap">[[multimap]]</a>
|
| 418 |
|
| 419 |
#### Class template `multimap` overview <a id="multimap.overview">[[multimap.overview]]</a>
|
| 420 |
|
|
@@ -425,13 +584,13 @@ for fast retrieval of values of another type `T` based on the keys. The
|
|
| 425 |
|
| 426 |
A `multimap` satisfies all of the requirements of a container and of a
|
| 427 |
reversible container ([[container.requirements]]), of an associative
|
| 428 |
container ([[associative.reqmts]]), and of an allocator-aware container
|
| 429 |
(Table [[tab:containers.allocatoraware]]). A `multimap` also provides
|
| 430 |
-
most operations described in
|
| 431 |
-
This means that a `multimap` supports the `a_eq` operations in
|
| 432 |
-
[[associative.reqmts]]
|
| 433 |
`multimap<Key,T>` the `key_type` is `Key` and the `value_type` is
|
| 434 |
`pair<const Key,T>`. Descriptions are provided here only for operations
|
| 435 |
on `multimap` that are not described in one of those tables or for
|
| 436 |
operations where there is additional semantic information.
|
| 437 |
|
|
@@ -440,44 +599,41 @@ namespace std {
|
|
| 440 |
template <class Key, class T, class Compare = less<Key>,
|
| 441 |
class Allocator = allocator<pair<const Key, T>>>
|
| 442 |
class multimap {
|
| 443 |
public:
|
| 444 |
// types:
|
| 445 |
-
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
|
| 450 |
-
|
| 451 |
-
|
| 452 |
-
|
| 453 |
-
|
| 454 |
-
|
| 455 |
-
|
| 456 |
-
|
| 457 |
-
|
| 458 |
-
|
| 459 |
-
|
|
|
|
| 460 |
|
| 461 |
class value_compare {
|
| 462 |
friend class multimap;
|
| 463 |
protected:
|
| 464 |
Compare comp;
|
| 465 |
value_compare(Compare c) : comp(c) { }
|
| 466 |
public:
|
| 467 |
-
typedef bool result_type;
|
| 468 |
-
typedef value_type first_argument_type;
|
| 469 |
-
typedef value_type second_argument_type;
|
| 470 |
bool operator()(const value_type& x, const value_type& y) const {
|
| 471 |
return comp(x.first, y.first);
|
| 472 |
}
|
| 473 |
};
|
| 474 |
|
| 475 |
-
// construct/copy/destroy
|
| 476 |
multimap() : multimap(Compare()) { }
|
| 477 |
-
explicit multimap(const Compare& comp,
|
| 478 |
-
const Allocator& = Allocator());
|
| 479 |
template <class InputIterator>
|
| 480 |
multimap(InputIterator first, InputIterator last,
|
| 481 |
const Compare& comp = Compare(),
|
| 482 |
const Allocator& = Allocator());
|
| 483 |
multimap(const multimap& x);
|
|
@@ -493,11 +649,13 @@ namespace std {
|
|
| 493 |
: multimap(first, last, Compare(), a) { }
|
| 494 |
multimap(initializer_list<value_type> il, const Allocator& a)
|
| 495 |
: multimap(il, Compare(), a) { }
|
| 496 |
~multimap();
|
| 497 |
multimap& operator=(const multimap& x);
|
| 498 |
-
multimap& operator=(multimap&& x)
|
|
|
|
|
|
|
| 499 |
multimap& operator=(initializer_list<value_type>);
|
| 500 |
allocator_type get_allocator() const noexcept;
|
| 501 |
|
| 502 |
// iterators:
|
| 503 |
iterator begin() noexcept;
|
|
@@ -518,27 +676,46 @@ namespace std {
|
|
| 518 |
// capacity:
|
| 519 |
bool empty() const noexcept;
|
| 520 |
size_type size() const noexcept;
|
| 521 |
size_type max_size() const noexcept;
|
| 522 |
|
| 523 |
-
// modifiers
|
| 524 |
template <class... Args> iterator emplace(Args&&... args);
|
| 525 |
template <class... Args> iterator emplace_hint(const_iterator position, Args&&... args);
|
| 526 |
iterator insert(const value_type& x);
|
|
|
|
| 527 |
template <class P> iterator insert(P&& x);
|
| 528 |
iterator insert(const_iterator position, const value_type& x);
|
|
|
|
| 529 |
template <class P> iterator insert(const_iterator position, P&& x);
|
| 530 |
template <class InputIterator>
|
| 531 |
void insert(InputIterator first, InputIterator last);
|
| 532 |
void insert(initializer_list<value_type>);
|
| 533 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 534 |
iterator erase(const_iterator position);
|
| 535 |
size_type erase(const key_type& x);
|
| 536 |
iterator erase(const_iterator first, const_iterator last);
|
| 537 |
-
void
|
|
|
|
|
|
|
| 538 |
void clear() noexcept;
|
| 539 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 540 |
// observers:
|
| 541 |
key_compare key_comp() const;
|
| 542 |
value_compare value_comp() const;
|
| 543 |
|
| 544 |
// map operations:
|
|
@@ -558,20 +735,37 @@ namespace std {
|
|
| 558 |
iterator upper_bound(const key_type& x);
|
| 559 |
const_iterator upper_bound(const key_type& x) const;
|
| 560 |
template <class K> iterator upper_bound(const K& x);
|
| 561 |
template <class K> const_iterator upper_bound(const K& x) const;
|
| 562 |
|
| 563 |
-
pair<iterator,iterator>
|
| 564 |
-
|
| 565 |
-
pair<const_iterator,const_iterator>
|
| 566 |
-
equal_range(const key_type& x) const;
|
| 567 |
template <class K>
|
| 568 |
pair<iterator, iterator> equal_range(const K& x);
|
| 569 |
template <class K>
|
| 570 |
pair<const_iterator, const_iterator> equal_range(const K& x) const;
|
| 571 |
};
|
| 572 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 573 |
template <class Key, class T, class Compare, class Allocator>
|
| 574 |
bool operator==(const multimap<Key, T, Compare, Allocator>& x,
|
| 575 |
const multimap<Key, T, Compare, Allocator>& y);
|
| 576 |
template <class Key, class T, class Compare, class Allocator>
|
| 577 |
bool operator< (const multimap<Key, T, Compare, Allocator>& x,
|
|
@@ -587,22 +781,22 @@ namespace std {
|
|
| 587 |
const multimap<Key, T, Compare, Allocator>& y);
|
| 588 |
template <class Key, class T, class Compare, class Allocator>
|
| 589 |
bool operator<=(const multimap<Key, T, Compare, Allocator>& x,
|
| 590 |
const multimap<Key, T, Compare, Allocator>& y);
|
| 591 |
|
| 592 |
-
// specialized algorithms
|
| 593 |
template <class Key, class T, class Compare, class Allocator>
|
| 594 |
void swap(multimap<Key, T, Compare, Allocator>& x,
|
| 595 |
-
multimap<Key,T,Compare,Allocator>& y)
|
|
|
|
| 596 |
}
|
| 597 |
```
|
| 598 |
|
| 599 |
#### `multimap` constructors <a id="multimap.cons">[[multimap.cons]]</a>
|
| 600 |
|
| 601 |
``` cpp
|
| 602 |
-
explicit multimap(const Compare& comp,
|
| 603 |
-
const Allocator& = Allocator());
|
| 604 |
```
|
| 605 |
|
| 606 |
*Effects:* Constructs an empty `multimap` using the specified comparison
|
| 607 |
object and allocator.
|
| 608 |
|
|
@@ -613,14 +807,10 @@ template <class InputIterator>
|
|
| 613 |
multimap(InputIterator first, InputIterator last,
|
| 614 |
const Compare& comp = Compare(),
|
| 615 |
const Allocator& = Allocator());
|
| 616 |
```
|
| 617 |
|
| 618 |
-
*Requires:* If the iterator’s indirection operator returns an lvalue or
|
| 619 |
-
a const rvalue `pair<key_type, mapped_type>`, then both `key_type` and
|
| 620 |
-
`mapped_type` shall be `CopyInsertable` into `*this`.
|
| 621 |
-
|
| 622 |
*Effects:* Constructs an empty `multimap` using the specified comparison
|
| 623 |
object and allocator, and inserts elements from the range \[`first`,
|
| 624 |
`last`).
|
| 625 |
|
| 626 |
*Complexity:* Linear in N if the range \[`first`, `last`) is already
|
|
@@ -636,25 +826,22 @@ template <class P> iterator insert(const_iterator position, P&& x);
|
|
| 636 |
*Effects:* The first form is equivalent to
|
| 637 |
`return emplace(std::forward<P>(x))`. The second form is equivalent to
|
| 638 |
`return emplace_hint(position, std::forward<P>(x))`.
|
| 639 |
|
| 640 |
*Remarks:* These signatures shall not participate in overload resolution
|
| 641 |
-
unless `
|
| 642 |
|
| 643 |
#### `multimap` specialized algorithms <a id="multimap.special">[[multimap.special]]</a>
|
| 644 |
|
| 645 |
``` cpp
|
| 646 |
template <class Key, class T, class Compare, class Allocator>
|
| 647 |
void swap(multimap<Key, T, Compare, Allocator>& x,
|
| 648 |
-
multimap<Key,T,Compare,Allocator>& y)
|
|
|
|
| 649 |
```
|
| 650 |
|
| 651 |
-
*Effects:*
|
| 652 |
-
|
| 653 |
-
``` cpp
|
| 654 |
-
x.swap(y);
|
| 655 |
-
```
|
| 656 |
|
| 657 |
### Class template `set` <a id="set">[[set]]</a>
|
| 658 |
|
| 659 |
#### Class template `set` overview <a id="set.overview">[[set.overview]]</a>
|
| 660 |
|
|
@@ -664,13 +851,13 @@ keys themselves. The `set` class supports bidirectional iterators.
|
|
| 664 |
|
| 665 |
A `set` satisfies all of the requirements of a container, of a
|
| 666 |
reversible container ([[container.requirements]]), of an associative
|
| 667 |
container ([[associative.reqmts]]), and of an allocator-aware container
|
| 668 |
(Table [[tab:containers.allocatoraware]]). A `set` also provides most
|
| 669 |
-
operations described in
|
| 670 |
-
means that a `set` supports the `a_uniq` operations in
|
| 671 |
-
[[associative.reqmts]]
|
| 672 |
both the `key_type` and `value_type` are `Key`. Descriptions are
|
| 673 |
provided here only for operations on `set` that are not described in one
|
| 674 |
of these tables and for operations where there is additional semantic
|
| 675 |
information.
|
| 676 |
|
|
@@ -679,49 +866,51 @@ namespace std {
|
|
| 679 |
template <class Key, class Compare = less<Key>,
|
| 680 |
class Allocator = allocator<Key>>
|
| 681 |
class set {
|
| 682 |
public:
|
| 683 |
// types:
|
| 684 |
-
|
| 685 |
-
|
| 686 |
-
|
| 687 |
-
|
| 688 |
-
|
| 689 |
-
|
| 690 |
-
|
| 691 |
-
|
| 692 |
-
|
| 693 |
-
|
| 694 |
-
|
| 695 |
-
|
| 696 |
-
|
| 697 |
-
|
| 698 |
-
|
|
|
|
|
|
|
| 699 |
|
| 700 |
-
// [set.cons], construct/copy/destroy
|
| 701 |
set() : set(Compare()) { }
|
| 702 |
-
explicit set(const Compare& comp,
|
| 703 |
-
const Allocator& = Allocator());
|
| 704 |
template <class InputIterator>
|
| 705 |
set(InputIterator first, InputIterator last,
|
| 706 |
const Compare& comp = Compare(), const Allocator& = Allocator());
|
| 707 |
set(const set& x);
|
| 708 |
set(set&& x);
|
| 709 |
explicit set(const Allocator&);
|
| 710 |
set(const set&, const Allocator&);
|
| 711 |
set(set&&, const Allocator&);
|
| 712 |
-
set(initializer_list<value_type>,
|
| 713 |
-
const Compare& = Compare(),
|
| 714 |
const Allocator& = Allocator());
|
| 715 |
template <class InputIterator>
|
| 716 |
set(InputIterator first, InputIterator last, const Allocator& a)
|
| 717 |
: set(first, last, Compare(), a) { }
|
| 718 |
set(initializer_list<value_type> il, const Allocator& a)
|
| 719 |
: set(il, Compare(), a) { }
|
| 720 |
~set();
|
| 721 |
set& operator=(const set& x);
|
| 722 |
-
set& operator=(set&& x)
|
|
|
|
|
|
|
| 723 |
set& operator=(initializer_list<value_type>);
|
| 724 |
allocator_type get_allocator() const noexcept;
|
| 725 |
|
| 726 |
// iterators:
|
| 727 |
iterator begin() noexcept;
|
|
@@ -753,16 +942,33 @@ namespace std {
|
|
| 753 |
iterator insert(const_iterator position, value_type&& x);
|
| 754 |
template <class InputIterator>
|
| 755 |
void insert(InputIterator first, InputIterator last);
|
| 756 |
void insert(initializer_list<value_type>);
|
| 757 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 758 |
iterator erase(const_iterator position);
|
| 759 |
size_type erase(const key_type& x);
|
| 760 |
iterator erase(const_iterator first, const_iterator last);
|
| 761 |
-
void
|
|
|
|
|
|
|
| 762 |
void clear() noexcept;
|
| 763 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 764 |
// observers:
|
| 765 |
key_compare key_comp() const;
|
| 766 |
value_compare value_comp() const;
|
| 767 |
|
| 768 |
// set operations:
|
|
@@ -790,10 +996,29 @@ namespace std {
|
|
| 790 |
pair<iterator, iterator> equal_range(const K& x);
|
| 791 |
template <class K>
|
| 792 |
pair<const_iterator, const_iterator> equal_range(const K& x) const;
|
| 793 |
};
|
| 794 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 795 |
template <class Key, class Compare, class Allocator>
|
| 796 |
bool operator==(const set<Key, Compare, Allocator>& x,
|
| 797 |
const set<Key, Compare, Allocator>& y);
|
| 798 |
template <class Key, class Compare, class Allocator>
|
| 799 |
bool operator< (const set<Key, Compare, Allocator>& x,
|
|
@@ -809,25 +1034,25 @@ namespace std {
|
|
| 809 |
const set<Key, Compare, Allocator>& y);
|
| 810 |
template <class Key, class Compare, class Allocator>
|
| 811 |
bool operator<=(const set<Key, Compare, Allocator>& x,
|
| 812 |
const set<Key, Compare, Allocator>& y);
|
| 813 |
|
| 814 |
-
// specialized algorithms
|
| 815 |
template <class Key, class Compare, class Allocator>
|
| 816 |
void swap(set<Key, Compare, Allocator>& x,
|
| 817 |
-
set<Key,Compare,Allocator>& y)
|
|
|
|
| 818 |
}
|
| 819 |
```
|
| 820 |
|
| 821 |
#### `set` constructors, copy, and assignment <a id="set.cons">[[set.cons]]</a>
|
| 822 |
|
| 823 |
``` cpp
|
| 824 |
-
explicit set(const Compare& comp,
|
| 825 |
-
const Allocator& = Allocator());
|
| 826 |
```
|
| 827 |
|
| 828 |
-
*Effects:* Constructs an empty set using the specified comparison
|
| 829 |
objects and allocator.
|
| 830 |
|
| 831 |
*Complexity:* Constant.
|
| 832 |
|
| 833 |
``` cpp
|
|
@@ -838,29 +1063,23 @@ template <class InputIterator>
|
|
| 838 |
|
| 839 |
*Effects:* Constructs an empty `set` using the specified comparison
|
| 840 |
object and allocator, and inserts elements from the range \[`first`,
|
| 841 |
`last`).
|
| 842 |
|
| 843 |
-
*Requires:* If the iterator’s indirection operator returns an lvalue or
|
| 844 |
-
a non-const rvalue, then `Key` shall be `CopyInsertable` into `*this`.
|
| 845 |
-
|
| 846 |
*Complexity:* Linear in N if the range \[`first`, `last`) is already
|
| 847 |
sorted using `comp` and otherwise N log N, where N is `last - first`.
|
| 848 |
|
| 849 |
#### `set` specialized algorithms <a id="set.special">[[set.special]]</a>
|
| 850 |
|
| 851 |
``` cpp
|
| 852 |
template <class Key, class Compare, class Allocator>
|
| 853 |
void swap(set<Key, Compare, Allocator>& x,
|
| 854 |
-
set<Key,Compare,Allocator>& y)
|
|
|
|
| 855 |
```
|
| 856 |
|
| 857 |
-
*Effects:*
|
| 858 |
-
|
| 859 |
-
``` cpp
|
| 860 |
-
x.swap(y);
|
| 861 |
-
```
|
| 862 |
|
| 863 |
### Class template `multiset` <a id="multiset">[[multiset]]</a>
|
| 864 |
|
| 865 |
#### Class template `multiset` overview <a id="multiset.overview">[[multiset.overview]]</a>
|
| 866 |
|
|
@@ -871,13 +1090,13 @@ bidirectional iterators.
|
|
| 871 |
|
| 872 |
A `multiset` satisfies all of the requirements of a container, of a
|
| 873 |
reversible container ([[container.requirements]]), of an associative
|
| 874 |
container ([[associative.reqmts]]), and of an allocator-aware container
|
| 875 |
(Table [[tab:containers.allocatoraware]]). `multiset` also provides
|
| 876 |
-
most operations described in
|
| 877 |
-
|
| 878 |
-
[[associative.reqmts]]
|
| 879 |
`multiset<Key>` both the `key_type` and `value_type` are `Key`.
|
| 880 |
Descriptions are provided here only for operations on `multiset` that
|
| 881 |
are not described in one of these tables and for operations where there
|
| 882 |
is additional semantic information.
|
| 883 |
|
|
@@ -886,50 +1105,50 @@ namespace std {
|
|
| 886 |
template <class Key, class Compare = less<Key>,
|
| 887 |
class Allocator = allocator<Key>>
|
| 888 |
class multiset {
|
| 889 |
public:
|
| 890 |
// types:
|
| 891 |
-
|
| 892 |
-
|
| 893 |
-
|
| 894 |
-
|
| 895 |
-
|
| 896 |
-
|
| 897 |
-
|
| 898 |
-
|
| 899 |
-
|
| 900 |
-
|
| 901 |
-
|
| 902 |
-
|
| 903 |
-
|
| 904 |
-
|
| 905 |
-
|
|
|
|
| 906 |
|
| 907 |
-
// construct/copy/destroy
|
| 908 |
multiset() : multiset(Compare()) { }
|
| 909 |
-
explicit multiset(const Compare& comp,
|
| 910 |
-
const Allocator& = Allocator());
|
| 911 |
template <class InputIterator>
|
| 912 |
multiset(InputIterator first, InputIterator last,
|
| 913 |
-
const Compare& comp = Compare(),
|
| 914 |
-
const Allocator& = Allocator());
|
| 915 |
multiset(const multiset& x);
|
| 916 |
multiset(multiset&& x);
|
| 917 |
explicit multiset(const Allocator&);
|
| 918 |
multiset(const multiset&, const Allocator&);
|
| 919 |
multiset(multiset&&, const Allocator&);
|
| 920 |
-
multiset(initializer_list<value_type>,
|
| 921 |
-
const Compare& = Compare(),
|
| 922 |
const Allocator& = Allocator());
|
| 923 |
template <class InputIterator>
|
| 924 |
multiset(InputIterator first, InputIterator last, const Allocator& a)
|
| 925 |
: multiset(first, last, Compare(), a) { }
|
| 926 |
multiset(initializer_list<value_type> il, const Allocator& a)
|
| 927 |
: multiset(il, Compare(), a) { }
|
| 928 |
~multiset();
|
| 929 |
multiset& operator=(const multiset& x);
|
| 930 |
-
multiset& operator=(multiset&& x)
|
|
|
|
|
|
|
| 931 |
multiset& operator=(initializer_list<value_type>);
|
| 932 |
allocator_type get_allocator() const noexcept;
|
| 933 |
|
| 934 |
// iterators:
|
| 935 |
iterator begin() noexcept;
|
|
@@ -961,16 +1180,33 @@ namespace std {
|
|
| 961 |
iterator insert(const_iterator position, value_type&& x);
|
| 962 |
template <class InputIterator>
|
| 963 |
void insert(InputIterator first, InputIterator last);
|
| 964 |
void insert(initializer_list<value_type>);
|
| 965 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 966 |
iterator erase(const_iterator position);
|
| 967 |
size_type erase(const key_type& x);
|
| 968 |
iterator erase(const_iterator first, const_iterator last);
|
| 969 |
-
void
|
|
|
|
|
|
|
| 970 |
void clear() noexcept;
|
| 971 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 972 |
// observers:
|
| 973 |
key_compare key_comp() const;
|
| 974 |
value_compare value_comp() const;
|
| 975 |
|
| 976 |
// set operations:
|
|
@@ -998,10 +1234,29 @@ namespace std {
|
|
| 998 |
pair<iterator, iterator> equal_range(const K& x);
|
| 999 |
template <class K>
|
| 1000 |
pair<const_iterator, const_iterator> equal_range(const K& x) const;
|
| 1001 |
};
|
| 1002 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1003 |
template <class Key, class Compare, class Allocator>
|
| 1004 |
bool operator==(const multiset<Key, Compare, Allocator>& x,
|
| 1005 |
const multiset<Key, Compare, Allocator>& y);
|
| 1006 |
template <class Key, class Compare, class Allocator>
|
| 1007 |
bool operator< (const multiset<Key, Compare, Allocator>& x,
|
|
@@ -1017,38 +1272,35 @@ namespace std {
|
|
| 1017 |
const multiset<Key, Compare, Allocator>& y);
|
| 1018 |
template <class Key, class Compare, class Allocator>
|
| 1019 |
bool operator<=(const multiset<Key, Compare, Allocator>& x,
|
| 1020 |
const multiset<Key, Compare, Allocator>& y);
|
| 1021 |
|
| 1022 |
-
// specialized algorithms
|
| 1023 |
template <class Key, class Compare, class Allocator>
|
| 1024 |
void swap(multiset<Key, Compare, Allocator>& x,
|
| 1025 |
-
multiset<Key,Compare,Allocator>& y)
|
|
|
|
| 1026 |
}
|
| 1027 |
```
|
| 1028 |
|
| 1029 |
#### `multiset` constructors <a id="multiset.cons">[[multiset.cons]]</a>
|
| 1030 |
|
| 1031 |
``` cpp
|
| 1032 |
-
explicit multiset(const Compare& comp,
|
| 1033 |
-
const Allocator& = Allocator());
|
| 1034 |
```
|
| 1035 |
|
| 1036 |
-
*Effects:* Constructs an empty
|
| 1037 |
-
and allocator.
|
| 1038 |
|
| 1039 |
*Complexity:* Constant.
|
| 1040 |
|
| 1041 |
``` cpp
|
| 1042 |
template <class InputIterator>
|
| 1043 |
multiset(InputIterator first, InputIterator last,
|
| 1044 |
const Compare& comp = Compare(), const Allocator& = Allocator());
|
| 1045 |
```
|
| 1046 |
|
| 1047 |
-
*Requires:* If the iterator’s indirection operator returns an lvalue or
|
| 1048 |
-
a const rvalue, then `Key` shall be `CopyInsertable` into `*this`.
|
| 1049 |
-
|
| 1050 |
*Effects:* Constructs an empty `multiset` using the specified comparison
|
| 1051 |
object and allocator, and inserts elements from the range \[`first`,
|
| 1052 |
`last`).
|
| 1053 |
|
| 1054 |
*Complexity:* Linear in N if the range \[`first`, `last`) is already
|
|
@@ -1057,14 +1309,11 @@ sorted using `comp` and otherwise N log N, where N is `last - first`.
|
|
| 1057 |
#### `multiset` specialized algorithms <a id="multiset.special">[[multiset.special]]</a>
|
| 1058 |
|
| 1059 |
``` cpp
|
| 1060 |
template <class Key, class Compare, class Allocator>
|
| 1061 |
void swap(multiset<Key, Compare, Allocator>& x,
|
| 1062 |
-
multiset<Key,Compare,Allocator>& y)
|
|
|
|
| 1063 |
```
|
| 1064 |
|
| 1065 |
-
*Effects:*
|
| 1066 |
-
|
| 1067 |
-
``` cpp
|
| 1068 |
-
x.swap(y);
|
| 1069 |
-
```
|
| 1070 |
|
|
|
|
| 3 |
### In general <a id="associative.general">[[associative.general]]</a>
|
| 4 |
|
| 5 |
The header `<map>` defines the class templates `map` and `multimap`; the
|
| 6 |
header `<set>` defines the class templates `set` and `multiset`.
|
| 7 |
|
| 8 |
+
The following exposition-only alias templates may appear in deduction
|
| 9 |
+
guides for associative containers:
|
| 10 |
+
|
| 11 |
+
``` cpp
|
| 12 |
+
template<class InputIterator>
|
| 13 |
+
using iter_key_t = remove_const_t<
|
| 14 |
+
typename iterator_traits<InputIterator>::value_type::first_type>; // exposition only
|
| 15 |
+
template<class InputIterator>
|
| 16 |
+
using iter_val_t
|
| 17 |
+
= typename iterator_traits<InputIterator>::value_type::second_type; // exposition only
|
| 18 |
+
template<class InputIterator>
|
| 19 |
+
using iter_to_alloc_t
|
| 20 |
+
= pair<add_const_t<typename iterator_traits<InputIterator>::value_type::first_type>,
|
| 21 |
+
typename iterator_traits<InputIterator>::value_type::second_type>; // exposition only
|
| 22 |
+
```
|
| 23 |
+
|
| 24 |
### Header `<map>` synopsis <a id="associative.map.syn">[[associative.map.syn]]</a>
|
| 25 |
|
| 26 |
``` cpp
|
| 27 |
#include <initializer_list>
|
| 28 |
|
| 29 |
namespace std {
|
| 30 |
+
// [map], class template map
|
| 31 |
template <class Key, class T, class Compare = less<Key>,
|
| 32 |
class Allocator = allocator<pair<const Key, T>>>
|
| 33 |
class map;
|
| 34 |
template <class Key, class T, class Compare, class Allocator>
|
| 35 |
bool operator==(const map<Key, T, Compare, Allocator>& x,
|
|
|
|
| 49 |
template <class Key, class T, class Compare, class Allocator>
|
| 50 |
bool operator<=(const map<Key, T, Compare, Allocator>& x,
|
| 51 |
const map<Key, T, Compare, Allocator>& y);
|
| 52 |
template <class Key, class T, class Compare, class Allocator>
|
| 53 |
void swap(map<Key, T, Compare, Allocator>& x,
|
| 54 |
+
map<Key, T, Compare, Allocator>& y)
|
| 55 |
+
noexcept(noexcept(x.swap(y)));
|
| 56 |
|
| 57 |
+
// [multimap], class template multimap
|
| 58 |
template <class Key, class T, class Compare = less<Key>,
|
| 59 |
class Allocator = allocator<pair<const Key, T>>>
|
| 60 |
class multimap;
|
| 61 |
template <class Key, class T, class Compare, class Allocator>
|
| 62 |
bool operator==(const multimap<Key, T, Compare, Allocator>& x,
|
|
|
|
| 76 |
template <class Key, class T, class Compare, class Allocator>
|
| 77 |
bool operator<=(const multimap<Key, T, Compare, Allocator>& x,
|
| 78 |
const multimap<Key, T, Compare, Allocator>& y);
|
| 79 |
template <class Key, class T, class Compare, class Allocator>
|
| 80 |
void swap(multimap<Key, T, Compare, Allocator>& x,
|
| 81 |
+
multimap<Key, T, Compare, Allocator>& y)
|
| 82 |
+
noexcept(noexcept(x.swap(y)));
|
| 83 |
+
|
| 84 |
+
namespace pmr {
|
| 85 |
+
template <class Key, class T, class Compare = less<Key>>
|
| 86 |
+
using map = std::map<Key, T, Compare,
|
| 87 |
+
polymorphic_allocator<pair<const Key, T>>>;
|
| 88 |
+
|
| 89 |
+
template <class Key, class T, class Compare = less<Key>>
|
| 90 |
+
using multimap = std::multimap<Key, T, Compare,
|
| 91 |
+
polymorphic_allocator<pair<const Key, T>>>;
|
| 92 |
+
}
|
| 93 |
}
|
| 94 |
```
|
| 95 |
|
| 96 |
### Header `<set>` synopsis <a id="associative.set.syn">[[associative.set.syn]]</a>
|
| 97 |
|
| 98 |
``` cpp
|
| 99 |
#include <initializer_list>
|
| 100 |
|
| 101 |
namespace std {
|
| 102 |
+
// [set], class template set
|
| 103 |
template <class Key, class Compare = less<Key>,
|
| 104 |
class Allocator = allocator<Key>>
|
| 105 |
class set;
|
| 106 |
template <class Key, class Compare, class Allocator>
|
| 107 |
bool operator==(const set<Key, Compare, Allocator>& x,
|
|
|
|
| 121 |
template <class Key, class Compare, class Allocator>
|
| 122 |
bool operator<=(const set<Key, Compare, Allocator>& x,
|
| 123 |
const set<Key, Compare, Allocator>& y);
|
| 124 |
template <class Key, class Compare, class Allocator>
|
| 125 |
void swap(set<Key, Compare, Allocator>& x,
|
| 126 |
+
set<Key, Compare, Allocator>& y)
|
| 127 |
+
noexcept(noexcept(x.swap(y)));
|
| 128 |
|
| 129 |
+
// [multiset], class template multiset
|
| 130 |
template <class Key, class Compare = less<Key>,
|
| 131 |
class Allocator = allocator<Key>>
|
| 132 |
class multiset;
|
| 133 |
template <class Key, class Compare, class Allocator>
|
| 134 |
bool operator==(const multiset<Key, Compare, Allocator>& x,
|
|
|
|
| 148 |
template <class Key, class Compare, class Allocator>
|
| 149 |
bool operator<=(const multiset<Key, Compare, Allocator>& x,
|
| 150 |
const multiset<Key, Compare, Allocator>& y);
|
| 151 |
template <class Key, class Compare, class Allocator>
|
| 152 |
void swap(multiset<Key, Compare, Allocator>& x,
|
| 153 |
+
multiset<Key, Compare, Allocator>& y)
|
| 154 |
+
noexcept(noexcept(x.swap(y)));
|
| 155 |
+
|
| 156 |
+
namespace pmr {
|
| 157 |
+
template <class Key, class Compare = less<Key>>
|
| 158 |
+
using set = std::set<Key, Compare,
|
| 159 |
+
polymorphic_allocator<Key>>;
|
| 160 |
+
|
| 161 |
+
template <class Key, class Compare = less<Key>>
|
| 162 |
+
using multiset = std::multiset<Key, Compare,
|
| 163 |
+
polymorphic_allocator<Key>>;
|
| 164 |
+
}
|
| 165 |
}
|
| 166 |
```
|
| 167 |
|
| 168 |
### Class template `map` <a id="map">[[map]]</a>
|
| 169 |
|
|
|
|
| 176 |
|
| 177 |
A `map` satisfies all of the requirements of a container, of a
|
| 178 |
reversible container ([[container.requirements]]), of an associative
|
| 179 |
container ([[associative.reqmts]]), and of an allocator-aware container
|
| 180 |
(Table [[tab:containers.allocatoraware]]). A `map` also provides most
|
| 181 |
+
operations described in [[associative.reqmts]] for unique keys. This
|
| 182 |
+
means that a `map` supports the `a_uniq` operations in
|
| 183 |
+
[[associative.reqmts]] but not the `a_eq` operations. For a `map<Key,T>`
|
| 184 |
+
the `key_type` is `Key` and the `value_type` is `pair<const Key,T>`.
|
| 185 |
+
Descriptions are provided here only for operations on `map` that are not
|
| 186 |
+
described in one of those tables or for operations where there is
|
| 187 |
+
additional semantic information.
|
| 188 |
|
| 189 |
``` cpp
|
| 190 |
namespace std {
|
| 191 |
template <class Key, class T, class Compare = less<Key>,
|
| 192 |
class Allocator = allocator<pair<const Key, T>>>
|
| 193 |
class map {
|
| 194 |
public:
|
| 195 |
// types:
|
| 196 |
+
using key_type = Key;
|
| 197 |
+
using mapped_type = T;
|
| 198 |
+
using value_type = pair<const Key, T>;
|
| 199 |
+
using key_compare = Compare;
|
| 200 |
+
using allocator_type = Allocator;
|
| 201 |
+
using pointer = typename allocator_traits<Allocator>::pointer;
|
| 202 |
+
using const_pointer = typename allocator_traits<Allocator>::const_pointer;
|
| 203 |
+
using reference = value_type&;
|
| 204 |
+
using const_reference = const value_type&;
|
| 205 |
+
using size_type = implementation-defined; // see [container.requirements]
|
| 206 |
+
using difference_type = implementation-defined; // see [container.requirements]
|
| 207 |
+
using iterator = implementation-defined // type of map::iterator; // see [container.requirements]
|
| 208 |
+
using const_iterator = implementation-defined // type of map::const_iterator; // see [container.requirements]
|
| 209 |
+
using reverse_iterator = std::reverse_iterator<iterator>;
|
| 210 |
+
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
|
| 211 |
+
using node_type = unspecified;
|
| 212 |
+
using insert_return_type = INSERT_RETURN_TYPE<iterator, node_type>;
|
| 213 |
|
| 214 |
class value_compare {
|
| 215 |
friend class map;
|
| 216 |
protected:
|
| 217 |
Compare comp;
|
| 218 |
value_compare(Compare c) : comp(c) {}
|
| 219 |
public:
|
|
|
|
|
|
|
|
|
|
| 220 |
bool operator()(const value_type& x, const value_type& y) const {
|
| 221 |
return comp(x.first, y.first);
|
| 222 |
}
|
| 223 |
};
|
| 224 |
|
| 225 |
+
// [map.cons], construct/copy/destroy
|
| 226 |
map() : map(Compare()) { }
|
| 227 |
+
explicit map(const Compare& comp, const Allocator& = Allocator());
|
|
|
|
| 228 |
template <class InputIterator>
|
| 229 |
map(InputIterator first, InputIterator last,
|
| 230 |
const Compare& comp = Compare(), const Allocator& = Allocator());
|
| 231 |
map(const map& x);
|
| 232 |
map(map&& x);
|
|
|
|
| 241 |
: map(first, last, Compare(), a) { }
|
| 242 |
map(initializer_list<value_type> il, const Allocator& a)
|
| 243 |
: map(il, Compare(), a) { }
|
| 244 |
~map();
|
| 245 |
map& operator=(const map& x);
|
| 246 |
+
map& operator=(map&& x)
|
| 247 |
+
noexcept(allocator_traits<Allocator>::is_always_equal::value &&
|
| 248 |
+
is_nothrow_move_assignable_v<Compare>);
|
| 249 |
map& operator=(initializer_list<value_type>);
|
| 250 |
allocator_type get_allocator() const noexcept;
|
| 251 |
|
| 252 |
// iterators:
|
| 253 |
iterator begin() noexcept;
|
|
|
|
| 268 |
// capacity:
|
| 269 |
bool empty() const noexcept;
|
| 270 |
size_type size() const noexcept;
|
| 271 |
size_type max_size() const noexcept;
|
| 272 |
|
| 273 |
+
// [map.access], element access
|
| 274 |
T& operator[](const key_type& x);
|
| 275 |
T& operator[](key_type&& x);
|
| 276 |
T& at(const key_type& x);
|
| 277 |
const T& at(const key_type& x) const;
|
| 278 |
|
| 279 |
+
// [map.modifiers], modifiers
|
| 280 |
template <class... Args> pair<iterator, bool> emplace(Args&&... args);
|
| 281 |
template <class... Args> iterator emplace_hint(const_iterator position, Args&&... args);
|
| 282 |
pair<iterator, bool> insert(const value_type& x);
|
| 283 |
+
pair<iterator, bool> insert(value_type&& x);
|
| 284 |
template <class P> pair<iterator, bool> insert(P&& x);
|
| 285 |
iterator insert(const_iterator position, const value_type& x);
|
| 286 |
+
iterator insert(const_iterator position, value_type&& x);
|
| 287 |
template <class P>
|
| 288 |
iterator insert(const_iterator position, P&&);
|
| 289 |
template <class InputIterator>
|
| 290 |
void insert(InputIterator first, InputIterator last);
|
| 291 |
void insert(initializer_list<value_type>);
|
| 292 |
|
| 293 |
+
node_type extract(const_iterator position);
|
| 294 |
+
node_type extract(const key_type& x);
|
| 295 |
+
insert_return_type insert(node_type&& nh);
|
| 296 |
+
iterator insert(const_iterator hint, node_type&& nh);
|
| 297 |
+
|
| 298 |
+
template <class... Args>
|
| 299 |
+
pair<iterator, bool> try_emplace(const key_type& k, Args&&... args);
|
| 300 |
+
template <class... Args>
|
| 301 |
+
pair<iterator, bool> try_emplace(key_type&& k, Args&&... args);
|
| 302 |
+
template <class... Args>
|
| 303 |
+
iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args);
|
| 304 |
+
template <class... Args>
|
| 305 |
+
iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args);
|
| 306 |
+
template <class M>
|
| 307 |
+
pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj);
|
| 308 |
+
template <class M>
|
| 309 |
+
pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj);
|
| 310 |
+
template <class M>
|
| 311 |
+
iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj);
|
| 312 |
+
template <class M>
|
| 313 |
+
iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj);
|
| 314 |
+
|
| 315 |
+
iterator erase(iterator position);
|
| 316 |
iterator erase(const_iterator position);
|
| 317 |
size_type erase(const key_type& x);
|
| 318 |
iterator erase(const_iterator first, const_iterator last);
|
| 319 |
+
void swap(map&)
|
| 320 |
+
noexcept(allocator_traits<Allocator>::is_always_equal::value &&
|
| 321 |
+
is_nothrow_swappable_v<Compare>);
|
| 322 |
void clear() noexcept;
|
| 323 |
|
| 324 |
+
template<class C2>
|
| 325 |
+
void merge(map<Key, T, C2, Allocator>& source);
|
| 326 |
+
template<class C2>
|
| 327 |
+
void merge(map<Key, T, C2, Allocator>&& source);
|
| 328 |
+
template<class C2>
|
| 329 |
+
void merge(multimap<Key, T, C2, Allocator>& source);
|
| 330 |
+
template<class C2>
|
| 331 |
+
void merge(multimap<Key, T, C2, Allocator>&& source);
|
| 332 |
+
|
| 333 |
// observers:
|
| 334 |
key_compare key_comp() const;
|
| 335 |
value_compare value_comp() const;
|
| 336 |
|
| 337 |
// map operations:
|
|
|
|
| 351 |
iterator upper_bound(const key_type& x);
|
| 352 |
const_iterator upper_bound(const key_type& x) const;
|
| 353 |
template <class K> iterator upper_bound(const K& x);
|
| 354 |
template <class K> const_iterator upper_bound(const K& x) const;
|
| 355 |
|
| 356 |
+
pair<iterator, iterator> equal_range(const key_type& x);
|
| 357 |
+
pair<const_iterator, const_iterator> equal_range(const key_type& x) const;
|
|
|
|
|
|
|
| 358 |
template <class K>
|
| 359 |
pair<iterator, iterator> equal_range(const K& x);
|
| 360 |
template <class K>
|
| 361 |
pair<const_iterator, const_iterator> equal_range(const K& x) const;
|
| 362 |
};
|
| 363 |
|
| 364 |
+
template<class InputIterator, class Compare = less<iter_key_t<InputIterator>>,
|
| 365 |
+
class Allocator = allocator<iter_to_alloc_t<InputIterator>>>
|
| 366 |
+
map(InputIterator, InputIterator, Compare = Compare(), Allocator = Allocator())
|
| 367 |
+
-> map<iter_key_t<InputIterator>, iter_val_t<InputIterator>, Compare, Allocator>;
|
| 368 |
+
|
| 369 |
+
template<class Key, class T, class Compare = less<Key>,
|
| 370 |
+
class Allocator = allocator<pair<const Key, T>>>
|
| 371 |
+
map(initializer_list<pair<const Key, T>>, Compare = Compare(), Allocator = Allocator())
|
| 372 |
+
-> map<Key, T, Compare, Allocator>;
|
| 373 |
+
|
| 374 |
+
template <class InputIterator, class Allocator>
|
| 375 |
+
map(InputIterator, InputIterator, Allocator)
|
| 376 |
+
-> map<iter_key_t<InputIterator>, iter_val_t<InputIterator>,
|
| 377 |
+
less<iter_key_t<InputIterator>>, Allocator>;
|
| 378 |
+
|
| 379 |
+
template<class Key, class T, class Allocator>
|
| 380 |
+
map(initializer_list<pair<const Key, T>>, Allocator) -> map<Key, T, less<Key>, Allocator>;
|
| 381 |
+
|
| 382 |
template <class Key, class T, class Compare, class Allocator>
|
| 383 |
bool operator==(const map<Key, T, Compare, Allocator>& x,
|
| 384 |
const map<Key, T, Compare, Allocator>& y);
|
| 385 |
template <class Key, class T, class Compare, class Allocator>
|
| 386 |
bool operator< (const map<Key, T, Compare, Allocator>& x,
|
|
|
|
| 396 |
const map<Key, T, Compare, Allocator>& y);
|
| 397 |
template <class Key, class T, class Compare, class Allocator>
|
| 398 |
bool operator<=(const map<Key, T, Compare, Allocator>& x,
|
| 399 |
const map<Key, T, Compare, Allocator>& y);
|
| 400 |
|
| 401 |
+
// [map.special], specialized algorithms
|
| 402 |
template <class Key, class T, class Compare, class Allocator>
|
| 403 |
void swap(map<Key, T, Compare, Allocator>& x,
|
| 404 |
+
map<Key, T, Compare, Allocator>& y)
|
| 405 |
+
noexcept(noexcept(x.swap(y)));
|
| 406 |
}
|
| 407 |
```
|
| 408 |
|
| 409 |
#### `map` constructors, copy, and assignment <a id="map.cons">[[map.cons]]</a>
|
| 410 |
|
| 411 |
``` cpp
|
| 412 |
+
explicit map(const Compare& comp, const Allocator& = Allocator());
|
|
|
|
| 413 |
```
|
| 414 |
|
| 415 |
*Effects:* Constructs an empty `map` using the specified comparison
|
| 416 |
object and allocator.
|
| 417 |
|
|
|
|
| 421 |
template <class InputIterator>
|
| 422 |
map(InputIterator first, InputIterator last,
|
| 423 |
const Compare& comp = Compare(), const Allocator& = Allocator());
|
| 424 |
```
|
| 425 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 426 |
*Effects:* Constructs an empty `map` using the specified comparison
|
| 427 |
object and allocator, and inserts elements from the range \[`first`,
|
| 428 |
`last`).
|
| 429 |
|
| 430 |
*Complexity:* Linear in N if the range \[`first`, `last`) is already
|
| 431 |
+
sorted using `comp` and otherwise N log N, where N is `last - first`.
|
| 432 |
|
| 433 |
#### `map` element access <a id="map.access">[[map.access]]</a>
|
| 434 |
|
| 435 |
``` cpp
|
| 436 |
T& operator[](const key_type& x);
|
| 437 |
```
|
| 438 |
|
| 439 |
+
*Effects:* Equivalent to: `return try_emplace(x).first->second;`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 440 |
|
| 441 |
``` cpp
|
| 442 |
T& operator[](key_type&& x);
|
| 443 |
```
|
| 444 |
|
| 445 |
+
*Effects:* Equivalent to: `return try_emplace(move(x)).first->second;`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 446 |
|
| 447 |
``` cpp
|
| 448 |
T& at(const key_type& x);
|
| 449 |
const T& at(const key_type& x) const;
|
| 450 |
```
|
|
|
|
| 458 |
*Complexity:* Logarithmic.
|
| 459 |
|
| 460 |
#### `map` modifiers <a id="map.modifiers">[[map.modifiers]]</a>
|
| 461 |
|
| 462 |
``` cpp
|
| 463 |
+
template <class P>
|
| 464 |
+
pair<iterator, bool> insert(P&& x);
|
| 465 |
+
template <class P>
|
| 466 |
+
iterator insert(const_iterator position, P&& x);
|
| 467 |
```
|
| 468 |
|
| 469 |
*Effects:* The first form is equivalent to
|
| 470 |
`return emplace(std::forward<P>(x))`. The second form is equivalent to
|
| 471 |
`return emplace_hint(position, std::forward<P>(x))`.
|
| 472 |
|
| 473 |
*Remarks:* These signatures shall not participate in overload resolution
|
| 474 |
+
unless `is_constructible_v<value_type, P&&>` is `true`.
|
| 475 |
+
|
| 476 |
+
``` cpp
|
| 477 |
+
template <class... Args>
|
| 478 |
+
pair<iterator, bool> try_emplace(const key_type& k, Args&&... args);
|
| 479 |
+
template <class... Args>
|
| 480 |
+
iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args);
|
| 481 |
+
```
|
| 482 |
+
|
| 483 |
+
*Requires:* `value_type` shall be `EmplaceConstructible` into `map` from
|
| 484 |
+
`piecewise_construct`, `forward_as_tuple(k)`,
|
| 485 |
+
`forward_as_tuple(std::forward<Args>(args)...)`.
|
| 486 |
+
|
| 487 |
+
*Effects:* If the map already contains an element whose key is
|
| 488 |
+
equivalent to `k`, there is no effect. Otherwise inserts an object of
|
| 489 |
+
type `value_type` constructed with `piecewise_construct`,
|
| 490 |
+
`forward_as_tuple(k)`, `forward_as_tuple(std::forward<Args>(args)...)`.
|
| 491 |
+
|
| 492 |
+
*Returns:* In the first overload, the `bool` component of the returned
|
| 493 |
+
pair is `true` if and only if the insertion took place. The returned
|
| 494 |
+
iterator points to the map element whose key is equivalent to `k`.
|
| 495 |
+
|
| 496 |
+
*Complexity:* The same as `emplace` and `emplace_hint`, respectively.
|
| 497 |
+
|
| 498 |
+
``` cpp
|
| 499 |
+
template <class... Args>
|
| 500 |
+
pair<iterator, bool> try_emplace(key_type&& k, Args&&... args);
|
| 501 |
+
template <class... Args>
|
| 502 |
+
iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args);
|
| 503 |
+
```
|
| 504 |
+
|
| 505 |
+
*Requires:* `value_type` shall be `EmplaceConstructible` into `map` from
|
| 506 |
+
`piecewise_construct`, `forward_as_tuple(std::move(k))`,
|
| 507 |
+
`forward_as_tuple(std::forward<Args>(args)...)`.
|
| 508 |
+
|
| 509 |
+
*Effects:* If the map already contains an element whose key is
|
| 510 |
+
equivalent to `k`, there is no effect. Otherwise inserts an object of
|
| 511 |
+
type `value_type` constructed with `piecewise_construct`,
|
| 512 |
+
`forward_as_tuple(std::move(k))`,
|
| 513 |
+
`forward_as_tuple(std::forward<Args>(args)...)`.
|
| 514 |
+
|
| 515 |
+
*Returns:* In the first overload, the `bool` component of the returned
|
| 516 |
+
pair is `true` if and only if the insertion took place. The returned
|
| 517 |
+
iterator points to the map element whose key is equivalent to `k`.
|
| 518 |
+
|
| 519 |
+
*Complexity:* The same as `emplace` and `emplace_hint`, respectively.
|
| 520 |
+
|
| 521 |
+
``` cpp
|
| 522 |
+
template <class M>
|
| 523 |
+
pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj);
|
| 524 |
+
template <class M>
|
| 525 |
+
iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj);
|
| 526 |
+
```
|
| 527 |
+
|
| 528 |
+
*Requires:* `is_assignable_v<mapped_type&, M&&>` shall be `true`.
|
| 529 |
+
`value_type` shall be `EmplaceConstructible` into `map` from `k`,
|
| 530 |
+
`forward<M>(obj)`.
|
| 531 |
+
|
| 532 |
+
*Effects:* If the map already contains an element `e` whose key is
|
| 533 |
+
equivalent to `k`, assigns `std::forward<M>(obj)` to `e.second`.
|
| 534 |
+
Otherwise inserts an object of type `value_type` constructed with `k`,
|
| 535 |
+
`std::forward<M>(obj)`.
|
| 536 |
+
|
| 537 |
+
*Returns:* In the first overload, the `bool` component of the returned
|
| 538 |
+
pair is `true` if and only if the insertion took place. The returned
|
| 539 |
+
iterator points to the map element whose key is equivalent to `k`.
|
| 540 |
+
|
| 541 |
+
*Complexity:* The same as `emplace` and `emplace_hint`, respectively.
|
| 542 |
+
|
| 543 |
+
``` cpp
|
| 544 |
+
template <class M>
|
| 545 |
+
pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj);
|
| 546 |
+
template <class M>
|
| 547 |
+
iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj);
|
| 548 |
+
```
|
| 549 |
+
|
| 550 |
+
*Requires:* `is_assignable_v<mapped_type&, M&&>` shall be `true`.
|
| 551 |
+
`value_type` shall be `EmplaceConstructible` into `map` from `move(k)`,
|
| 552 |
+
`forward<M>(obj)`.
|
| 553 |
+
|
| 554 |
+
*Effects:* If the map already contains an element `e` whose key is
|
| 555 |
+
equivalent to `k`, assigns `std::forward<M>(obj)` to `e.second`.
|
| 556 |
+
Otherwise inserts an object of type `value_type` constructed with
|
| 557 |
+
`std::move(k)`, `std::forward<M>(obj)`.
|
| 558 |
+
|
| 559 |
+
*Returns:* In the first overload, the `bool` component of the returned
|
| 560 |
+
pair is `true` if and only if the insertion took place. The returned
|
| 561 |
+
iterator points to the map element whose key is equivalent to `k`.
|
| 562 |
+
|
| 563 |
+
*Complexity:* The same as `emplace` and `emplace_hint`, respectively.
|
| 564 |
|
| 565 |
#### `map` specialized algorithms <a id="map.special">[[map.special]]</a>
|
| 566 |
|
| 567 |
``` cpp
|
| 568 |
template <class Key, class T, class Compare, class Allocator>
|
| 569 |
void swap(map<Key, T, Compare, Allocator>& x,
|
| 570 |
+
map<Key, T, Compare, Allocator>& y)
|
| 571 |
+
noexcept(noexcept(x.swap(y)));
|
| 572 |
```
|
| 573 |
|
| 574 |
+
*Effects:* As if by `x.swap(y)`.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 575 |
|
| 576 |
### Class template `multimap` <a id="multimap">[[multimap]]</a>
|
| 577 |
|
| 578 |
#### Class template `multimap` overview <a id="multimap.overview">[[multimap.overview]]</a>
|
| 579 |
|
|
|
|
| 584 |
|
| 585 |
A `multimap` satisfies all of the requirements of a container and of a
|
| 586 |
reversible container ([[container.requirements]]), of an associative
|
| 587 |
container ([[associative.reqmts]]), and of an allocator-aware container
|
| 588 |
(Table [[tab:containers.allocatoraware]]). A `multimap` also provides
|
| 589 |
+
most operations described in [[associative.reqmts]] for equal keys.
|
| 590 |
+
This means that a `multimap` supports the `a_eq` operations in
|
| 591 |
+
[[associative.reqmts]] but not the `a_uniq` operations. For a
|
| 592 |
`multimap<Key,T>` the `key_type` is `Key` and the `value_type` is
|
| 593 |
`pair<const Key,T>`. Descriptions are provided here only for operations
|
| 594 |
on `multimap` that are not described in one of those tables or for
|
| 595 |
operations where there is additional semantic information.
|
| 596 |
|
|
|
|
| 599 |
template <class Key, class T, class Compare = less<Key>,
|
| 600 |
class Allocator = allocator<pair<const Key, T>>>
|
| 601 |
class multimap {
|
| 602 |
public:
|
| 603 |
// types:
|
| 604 |
+
using key_type = Key;
|
| 605 |
+
using mapped_type = T;
|
| 606 |
+
using value_type = pair<const Key, T>;
|
| 607 |
+
using key_compare = Compare;
|
| 608 |
+
using allocator_type = Allocator;
|
| 609 |
+
using pointer = typename allocator_traits<Allocator>::pointer;
|
| 610 |
+
using const_pointer = typename allocator_traits<Allocator>::const_pointer;
|
| 611 |
+
using reference = value_type&;
|
| 612 |
+
using const_reference = const value_type&;
|
| 613 |
+
using size_type = implementation-defined; // see [container.requirements]
|
| 614 |
+
using difference_type = implementation-defined; // see [container.requirements]
|
| 615 |
+
using iterator = implementation-defined // type of multimap::iterator; // see [container.requirements]
|
| 616 |
+
using const_iterator = implementation-defined // type of multimap::const_iterator; // see [container.requirements]
|
| 617 |
+
using reverse_iterator = std::reverse_iterator<iterator>;
|
| 618 |
+
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
|
| 619 |
+
using node_type = unspecified;
|
| 620 |
|
| 621 |
class value_compare {
|
| 622 |
friend class multimap;
|
| 623 |
protected:
|
| 624 |
Compare comp;
|
| 625 |
value_compare(Compare c) : comp(c) { }
|
| 626 |
public:
|
|
|
|
|
|
|
|
|
|
| 627 |
bool operator()(const value_type& x, const value_type& y) const {
|
| 628 |
return comp(x.first, y.first);
|
| 629 |
}
|
| 630 |
};
|
| 631 |
|
| 632 |
+
// [multimap.cons], construct/copy/destroy
|
| 633 |
multimap() : multimap(Compare()) { }
|
| 634 |
+
explicit multimap(const Compare& comp, const Allocator& = Allocator());
|
|
|
|
| 635 |
template <class InputIterator>
|
| 636 |
multimap(InputIterator first, InputIterator last,
|
| 637 |
const Compare& comp = Compare(),
|
| 638 |
const Allocator& = Allocator());
|
| 639 |
multimap(const multimap& x);
|
|
|
|
| 649 |
: multimap(first, last, Compare(), a) { }
|
| 650 |
multimap(initializer_list<value_type> il, const Allocator& a)
|
| 651 |
: multimap(il, Compare(), a) { }
|
| 652 |
~multimap();
|
| 653 |
multimap& operator=(const multimap& x);
|
| 654 |
+
multimap& operator=(multimap&& x)
|
| 655 |
+
noexcept(allocator_traits<Allocator>::is_always_equal::value &&
|
| 656 |
+
is_nothrow_move_assignable_v<Compare>);
|
| 657 |
multimap& operator=(initializer_list<value_type>);
|
| 658 |
allocator_type get_allocator() const noexcept;
|
| 659 |
|
| 660 |
// iterators:
|
| 661 |
iterator begin() noexcept;
|
|
|
|
| 676 |
// capacity:
|
| 677 |
bool empty() const noexcept;
|
| 678 |
size_type size() const noexcept;
|
| 679 |
size_type max_size() const noexcept;
|
| 680 |
|
| 681 |
+
// [multimap.modifiers], modifiers
|
| 682 |
template <class... Args> iterator emplace(Args&&... args);
|
| 683 |
template <class... Args> iterator emplace_hint(const_iterator position, Args&&... args);
|
| 684 |
iterator insert(const value_type& x);
|
| 685 |
+
iterator insert(value_type&& x);
|
| 686 |
template <class P> iterator insert(P&& x);
|
| 687 |
iterator insert(const_iterator position, const value_type& x);
|
| 688 |
+
iterator insert(const_iterator position, value_type&& x);
|
| 689 |
template <class P> iterator insert(const_iterator position, P&& x);
|
| 690 |
template <class InputIterator>
|
| 691 |
void insert(InputIterator first, InputIterator last);
|
| 692 |
void insert(initializer_list<value_type>);
|
| 693 |
|
| 694 |
+
node_type extract(const_iterator position);
|
| 695 |
+
node_type extract(const key_type& x);
|
| 696 |
+
iterator insert(node_type&& nh);
|
| 697 |
+
iterator insert(const_iterator hint, node_type&& nh);
|
| 698 |
+
|
| 699 |
+
iterator erase(iterator position);
|
| 700 |
iterator erase(const_iterator position);
|
| 701 |
size_type erase(const key_type& x);
|
| 702 |
iterator erase(const_iterator first, const_iterator last);
|
| 703 |
+
void swap(multimap&)
|
| 704 |
+
noexcept(allocator_traits<Allocator>::is_always_equal::value &&
|
| 705 |
+
is_nothrow_swappable_v<Compare>);
|
| 706 |
void clear() noexcept;
|
| 707 |
|
| 708 |
+
template<class C2>
|
| 709 |
+
void merge(multimap<Key, T, C2, Allocator>& source);
|
| 710 |
+
template<class C2>
|
| 711 |
+
void merge(multimap<Key, T, C2, Allocator>&& source);
|
| 712 |
+
template<class C2>
|
| 713 |
+
void merge(map<Key, T, C2, Allocator>& source);
|
| 714 |
+
template<class C2>
|
| 715 |
+
void merge(map<Key, T, C2, Allocator>&& source);
|
| 716 |
+
|
| 717 |
// observers:
|
| 718 |
key_compare key_comp() const;
|
| 719 |
value_compare value_comp() const;
|
| 720 |
|
| 721 |
// map operations:
|
|
|
|
| 735 |
iterator upper_bound(const key_type& x);
|
| 736 |
const_iterator upper_bound(const key_type& x) const;
|
| 737 |
template <class K> iterator upper_bound(const K& x);
|
| 738 |
template <class K> const_iterator upper_bound(const K& x) const;
|
| 739 |
|
| 740 |
+
pair<iterator, iterator> equal_range(const key_type& x);
|
| 741 |
+
pair<const_iterator, const_iterator> equal_range(const key_type& x) const;
|
|
|
|
|
|
|
| 742 |
template <class K>
|
| 743 |
pair<iterator, iterator> equal_range(const K& x);
|
| 744 |
template <class K>
|
| 745 |
pair<const_iterator, const_iterator> equal_range(const K& x) const;
|
| 746 |
};
|
| 747 |
|
| 748 |
+
template<class InputIterator, class Compare = less<iter_key_t<InputIterator>>,
|
| 749 |
+
class Allocator = allocator<iter_to_alloc_t<InputIterator>>>
|
| 750 |
+
multimap(InputIterator, InputIterator, Compare = Compare(), Allocator = Allocator())
|
| 751 |
+
-> multimap<iter_key_t<InputIterator>, iter_val_t<InputIterator>, Compare, Allocator>;
|
| 752 |
+
|
| 753 |
+
template<class Key, class T, class Compare = less<Key>,
|
| 754 |
+
class Allocator = allocator<pair<const Key, T>>>
|
| 755 |
+
multimap(initializer_list<pair<const Key, T>>, Compare = Compare(), Allocator = Allocator())
|
| 756 |
+
-> multimap<Key, T, Compare, Allocator>;
|
| 757 |
+
|
| 758 |
+
template<class InputIterator, class Allocator>
|
| 759 |
+
multimap(InputIterator, InputIterator, Allocator)
|
| 760 |
+
-> multimap<iter_key_t<InputIterator>, iter_val_t<InputIterator>,
|
| 761 |
+
less<iter_key_t<InputIterator>>, Allocator>;
|
| 762 |
+
|
| 763 |
+
template<class Key, class T, class Allocator>
|
| 764 |
+
multimap(initializer_list<pair<const Key, T>>, Allocator)
|
| 765 |
+
-> multimap<Key, T, less<Key>, Allocator>;
|
| 766 |
+
|
| 767 |
template <class Key, class T, class Compare, class Allocator>
|
| 768 |
bool operator==(const multimap<Key, T, Compare, Allocator>& x,
|
| 769 |
const multimap<Key, T, Compare, Allocator>& y);
|
| 770 |
template <class Key, class T, class Compare, class Allocator>
|
| 771 |
bool operator< (const multimap<Key, T, Compare, Allocator>& x,
|
|
|
|
| 781 |
const multimap<Key, T, Compare, Allocator>& y);
|
| 782 |
template <class Key, class T, class Compare, class Allocator>
|
| 783 |
bool operator<=(const multimap<Key, T, Compare, Allocator>& x,
|
| 784 |
const multimap<Key, T, Compare, Allocator>& y);
|
| 785 |
|
| 786 |
+
// [multimap.special], specialized algorithms
|
| 787 |
template <class Key, class T, class Compare, class Allocator>
|
| 788 |
void swap(multimap<Key, T, Compare, Allocator>& x,
|
| 789 |
+
multimap<Key, T, Compare, Allocator>& y)
|
| 790 |
+
noexcept(noexcept(x.swap(y)));
|
| 791 |
}
|
| 792 |
```
|
| 793 |
|
| 794 |
#### `multimap` constructors <a id="multimap.cons">[[multimap.cons]]</a>
|
| 795 |
|
| 796 |
``` cpp
|
| 797 |
+
explicit multimap(const Compare& comp, const Allocator& = Allocator());
|
|
|
|
| 798 |
```
|
| 799 |
|
| 800 |
*Effects:* Constructs an empty `multimap` using the specified comparison
|
| 801 |
object and allocator.
|
| 802 |
|
|
|
|
| 807 |
multimap(InputIterator first, InputIterator last,
|
| 808 |
const Compare& comp = Compare(),
|
| 809 |
const Allocator& = Allocator());
|
| 810 |
```
|
| 811 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 812 |
*Effects:* Constructs an empty `multimap` using the specified comparison
|
| 813 |
object and allocator, and inserts elements from the range \[`first`,
|
| 814 |
`last`).
|
| 815 |
|
| 816 |
*Complexity:* Linear in N if the range \[`first`, `last`) is already
|
|
|
|
| 826 |
*Effects:* The first form is equivalent to
|
| 827 |
`return emplace(std::forward<P>(x))`. The second form is equivalent to
|
| 828 |
`return emplace_hint(position, std::forward<P>(x))`.
|
| 829 |
|
| 830 |
*Remarks:* These signatures shall not participate in overload resolution
|
| 831 |
+
unless `is_constructible_v<value_type, P&&>` is `true`.
|
| 832 |
|
| 833 |
#### `multimap` specialized algorithms <a id="multimap.special">[[multimap.special]]</a>
|
| 834 |
|
| 835 |
``` cpp
|
| 836 |
template <class Key, class T, class Compare, class Allocator>
|
| 837 |
void swap(multimap<Key, T, Compare, Allocator>& x,
|
| 838 |
+
multimap<Key, T, Compare, Allocator>& y)
|
| 839 |
+
noexcept(noexcept(x.swap(y)));
|
| 840 |
```
|
| 841 |
|
| 842 |
+
*Effects:* As if by `x.swap(y)`.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 843 |
|
| 844 |
### Class template `set` <a id="set">[[set]]</a>
|
| 845 |
|
| 846 |
#### Class template `set` overview <a id="set.overview">[[set.overview]]</a>
|
| 847 |
|
|
|
|
| 851 |
|
| 852 |
A `set` satisfies all of the requirements of a container, of a
|
| 853 |
reversible container ([[container.requirements]]), of an associative
|
| 854 |
container ([[associative.reqmts]]), and of an allocator-aware container
|
| 855 |
(Table [[tab:containers.allocatoraware]]). A `set` also provides most
|
| 856 |
+
operations described in [[associative.reqmts]] for unique keys. This
|
| 857 |
+
means that a `set` supports the `a_uniq` operations in
|
| 858 |
+
[[associative.reqmts]] but not the `a_eq` operations. For a `set<Key>`
|
| 859 |
both the `key_type` and `value_type` are `Key`. Descriptions are
|
| 860 |
provided here only for operations on `set` that are not described in one
|
| 861 |
of these tables and for operations where there is additional semantic
|
| 862 |
information.
|
| 863 |
|
|
|
|
| 866 |
template <class Key, class Compare = less<Key>,
|
| 867 |
class Allocator = allocator<Key>>
|
| 868 |
class set {
|
| 869 |
public:
|
| 870 |
// types:
|
| 871 |
+
using key_type = Key;
|
| 872 |
+
using key_compare = Compare;
|
| 873 |
+
using value_type = Key;
|
| 874 |
+
using value_compare = Compare;
|
| 875 |
+
using allocator_type = Allocator;
|
| 876 |
+
using pointer = typename allocator_traits<Allocator>::pointer;
|
| 877 |
+
using const_pointer = typename allocator_traits<Allocator>::const_pointer;
|
| 878 |
+
using reference = value_type&;
|
| 879 |
+
using const_reference = const value_type&;
|
| 880 |
+
using size_type = implementation-defined; // see [container.requirements]
|
| 881 |
+
using difference_type = implementation-defined; // see [container.requirements]
|
| 882 |
+
using iterator = implementation-defined // type of set::iterator; // see [container.requirements]
|
| 883 |
+
using const_iterator = implementation-defined // type of set::const_iterator; // see [container.requirements]
|
| 884 |
+
using reverse_iterator = std::reverse_iterator<iterator>;
|
| 885 |
+
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
|
| 886 |
+
using node_type = unspecified;
|
| 887 |
+
using insert_return_type = INSERT_RETURN_TYPE<iterator, node_type>;
|
| 888 |
|
| 889 |
+
// [set.cons], construct/copy/destroy
|
| 890 |
set() : set(Compare()) { }
|
| 891 |
+
explicit set(const Compare& comp, const Allocator& = Allocator());
|
|
|
|
| 892 |
template <class InputIterator>
|
| 893 |
set(InputIterator first, InputIterator last,
|
| 894 |
const Compare& comp = Compare(), const Allocator& = Allocator());
|
| 895 |
set(const set& x);
|
| 896 |
set(set&& x);
|
| 897 |
explicit set(const Allocator&);
|
| 898 |
set(const set&, const Allocator&);
|
| 899 |
set(set&&, const Allocator&);
|
| 900 |
+
set(initializer_list<value_type>, const Compare& = Compare(),
|
|
|
|
| 901 |
const Allocator& = Allocator());
|
| 902 |
template <class InputIterator>
|
| 903 |
set(InputIterator first, InputIterator last, const Allocator& a)
|
| 904 |
: set(first, last, Compare(), a) { }
|
| 905 |
set(initializer_list<value_type> il, const Allocator& a)
|
| 906 |
: set(il, Compare(), a) { }
|
| 907 |
~set();
|
| 908 |
set& operator=(const set& x);
|
| 909 |
+
set& operator=(set&& x)
|
| 910 |
+
noexcept(allocator_traits<Allocator>::is_always_equal::value &&
|
| 911 |
+
is_nothrow_move_assignable_v<Compare>);
|
| 912 |
set& operator=(initializer_list<value_type>);
|
| 913 |
allocator_type get_allocator() const noexcept;
|
| 914 |
|
| 915 |
// iterators:
|
| 916 |
iterator begin() noexcept;
|
|
|
|
| 942 |
iterator insert(const_iterator position, value_type&& x);
|
| 943 |
template <class InputIterator>
|
| 944 |
void insert(InputIterator first, InputIterator last);
|
| 945 |
void insert(initializer_list<value_type>);
|
| 946 |
|
| 947 |
+
node_type extract(const_iterator position);
|
| 948 |
+
node_type extract(const key_type& x);
|
| 949 |
+
insert_return_type insert(node_type&& nh);
|
| 950 |
+
iterator insert(const_iterator hint, node_type&& nh);
|
| 951 |
+
|
| 952 |
+
iterator erase(iterator position);
|
| 953 |
iterator erase(const_iterator position);
|
| 954 |
size_type erase(const key_type& x);
|
| 955 |
iterator erase(const_iterator first, const_iterator last);
|
| 956 |
+
void swap(set&)
|
| 957 |
+
noexcept(allocator_traits<Allocator>::is_always_equal::value &&
|
| 958 |
+
is_nothrow_swappable_v<Compare>);
|
| 959 |
void clear() noexcept;
|
| 960 |
|
| 961 |
+
template<class C2>
|
| 962 |
+
void merge(set<Key, C2, Allocator>& source);
|
| 963 |
+
template<class C2>
|
| 964 |
+
void merge(set<Key, C2, Allocator>&& source);
|
| 965 |
+
template<class C2>
|
| 966 |
+
void merge(multiset<Key, C2, Allocator>& source);
|
| 967 |
+
template<class C2>
|
| 968 |
+
void merge(multiset<Key, C2, Allocator>&& source);
|
| 969 |
+
|
| 970 |
// observers:
|
| 971 |
key_compare key_comp() const;
|
| 972 |
value_compare value_comp() const;
|
| 973 |
|
| 974 |
// set operations:
|
|
|
|
| 996 |
pair<iterator, iterator> equal_range(const K& x);
|
| 997 |
template <class K>
|
| 998 |
pair<const_iterator, const_iterator> equal_range(const K& x) const;
|
| 999 |
};
|
| 1000 |
|
| 1001 |
+
template<class InputIterator,
|
| 1002 |
+
class Compare = less<typename iterator_traits<InputIterator>::value_type>,
|
| 1003 |
+
class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>>
|
| 1004 |
+
set(InputIterator, InputIterator,
|
| 1005 |
+
Compare = Compare(), Allocator = Allocator())
|
| 1006 |
+
-> set<typename iterator_traits<InputIterator>::value_type, Compare, Allocator>;
|
| 1007 |
+
|
| 1008 |
+
template<class Key, class Compare = less<Key>, class Allocator = allocator<Key>>
|
| 1009 |
+
set(initializer_list<Key>, Compare = Compare(), Allocator = Allocator())
|
| 1010 |
+
-> set<Key, Compare, Allocator>;
|
| 1011 |
+
|
| 1012 |
+
template<class InputIterator, class Allocator>
|
| 1013 |
+
set(InputIterator, InputIterator, Allocator)
|
| 1014 |
+
-> set<typename iterator_traits<InputIterator>::value_type,
|
| 1015 |
+
less<typename iterator_traits<InputIterator>::value_type>, Allocator>;
|
| 1016 |
+
|
| 1017 |
+
template<class Key, class Allocator>
|
| 1018 |
+
set(initializer_list<Key>, Allocator) -> set<Key, less<Key>, Allocator>;
|
| 1019 |
+
|
| 1020 |
template <class Key, class Compare, class Allocator>
|
| 1021 |
bool operator==(const set<Key, Compare, Allocator>& x,
|
| 1022 |
const set<Key, Compare, Allocator>& y);
|
| 1023 |
template <class Key, class Compare, class Allocator>
|
| 1024 |
bool operator< (const set<Key, Compare, Allocator>& x,
|
|
|
|
| 1034 |
const set<Key, Compare, Allocator>& y);
|
| 1035 |
template <class Key, class Compare, class Allocator>
|
| 1036 |
bool operator<=(const set<Key, Compare, Allocator>& x,
|
| 1037 |
const set<Key, Compare, Allocator>& y);
|
| 1038 |
|
| 1039 |
+
// [set.special], specialized algorithms
|
| 1040 |
template <class Key, class Compare, class Allocator>
|
| 1041 |
void swap(set<Key, Compare, Allocator>& x,
|
| 1042 |
+
set<Key, Compare, Allocator>& y)
|
| 1043 |
+
noexcept(noexcept(x.swap(y)));
|
| 1044 |
}
|
| 1045 |
```
|
| 1046 |
|
| 1047 |
#### `set` constructors, copy, and assignment <a id="set.cons">[[set.cons]]</a>
|
| 1048 |
|
| 1049 |
``` cpp
|
| 1050 |
+
explicit set(const Compare& comp, const Allocator& = Allocator());
|
|
|
|
| 1051 |
```
|
| 1052 |
|
| 1053 |
+
*Effects:* Constructs an empty `set` using the specified comparison
|
| 1054 |
objects and allocator.
|
| 1055 |
|
| 1056 |
*Complexity:* Constant.
|
| 1057 |
|
| 1058 |
``` cpp
|
|
|
|
| 1063 |
|
| 1064 |
*Effects:* Constructs an empty `set` using the specified comparison
|
| 1065 |
object and allocator, and inserts elements from the range \[`first`,
|
| 1066 |
`last`).
|
| 1067 |
|
|
|
|
|
|
|
|
|
|
| 1068 |
*Complexity:* Linear in N if the range \[`first`, `last`) is already
|
| 1069 |
sorted using `comp` and otherwise N log N, where N is `last - first`.
|
| 1070 |
|
| 1071 |
#### `set` specialized algorithms <a id="set.special">[[set.special]]</a>
|
| 1072 |
|
| 1073 |
``` cpp
|
| 1074 |
template <class Key, class Compare, class Allocator>
|
| 1075 |
void swap(set<Key, Compare, Allocator>& x,
|
| 1076 |
+
set<Key, Compare, Allocator>& y)
|
| 1077 |
+
noexcept(noexcept(x.swap(y)));
|
| 1078 |
```
|
| 1079 |
|
| 1080 |
+
*Effects:* As if by `x.swap(y)`.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1081 |
|
| 1082 |
### Class template `multiset` <a id="multiset">[[multiset]]</a>
|
| 1083 |
|
| 1084 |
#### Class template `multiset` overview <a id="multiset.overview">[[multiset.overview]]</a>
|
| 1085 |
|
|
|
|
| 1090 |
|
| 1091 |
A `multiset` satisfies all of the requirements of a container, of a
|
| 1092 |
reversible container ([[container.requirements]]), of an associative
|
| 1093 |
container ([[associative.reqmts]]), and of an allocator-aware container
|
| 1094 |
(Table [[tab:containers.allocatoraware]]). `multiset` also provides
|
| 1095 |
+
most operations described in [[associative.reqmts]] for duplicate keys.
|
| 1096 |
+
This means that a `multiset` supports the `a_eq` operations in
|
| 1097 |
+
[[associative.reqmts]] but not the `a_uniq` operations. For a
|
| 1098 |
`multiset<Key>` both the `key_type` and `value_type` are `Key`.
|
| 1099 |
Descriptions are provided here only for operations on `multiset` that
|
| 1100 |
are not described in one of these tables and for operations where there
|
| 1101 |
is additional semantic information.
|
| 1102 |
|
|
|
|
| 1105 |
template <class Key, class Compare = less<Key>,
|
| 1106 |
class Allocator = allocator<Key>>
|
| 1107 |
class multiset {
|
| 1108 |
public:
|
| 1109 |
// types:
|
| 1110 |
+
using key_type = Key;
|
| 1111 |
+
using key_compare = Compare;
|
| 1112 |
+
using value_type = Key;
|
| 1113 |
+
using value_compare = Compare;
|
| 1114 |
+
using allocator_type = Allocator;
|
| 1115 |
+
using pointer = typename allocator_traits<Allocator>::pointer;
|
| 1116 |
+
using const_pointer = typename allocator_traits<Allocator>::const_pointer;
|
| 1117 |
+
using reference = value_type&;
|
| 1118 |
+
using const_reference = const value_type&;
|
| 1119 |
+
using size_type = implementation-defined; // see [container.requirements]
|
| 1120 |
+
using difference_type = implementation-defined; // see [container.requirements]
|
| 1121 |
+
using iterator = implementation-defined // type of multiset::iterator; // see [container.requirements]
|
| 1122 |
+
using const_iterator = implementation-defined // type of multiset::const_iterator; // see [container.requirements]
|
| 1123 |
+
using reverse_iterator = std::reverse_iterator<iterator>;
|
| 1124 |
+
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
|
| 1125 |
+
using node_type = unspecified;
|
| 1126 |
|
| 1127 |
+
// [multiset.cons], construct/copy/destroy
|
| 1128 |
multiset() : multiset(Compare()) { }
|
| 1129 |
+
explicit multiset(const Compare& comp, const Allocator& = Allocator());
|
|
|
|
| 1130 |
template <class InputIterator>
|
| 1131 |
multiset(InputIterator first, InputIterator last,
|
| 1132 |
+
const Compare& comp = Compare(), const Allocator& = Allocator());
|
|
|
|
| 1133 |
multiset(const multiset& x);
|
| 1134 |
multiset(multiset&& x);
|
| 1135 |
explicit multiset(const Allocator&);
|
| 1136 |
multiset(const multiset&, const Allocator&);
|
| 1137 |
multiset(multiset&&, const Allocator&);
|
| 1138 |
+
multiset(initializer_list<value_type>, const Compare& = Compare(),
|
|
|
|
| 1139 |
const Allocator& = Allocator());
|
| 1140 |
template <class InputIterator>
|
| 1141 |
multiset(InputIterator first, InputIterator last, const Allocator& a)
|
| 1142 |
: multiset(first, last, Compare(), a) { }
|
| 1143 |
multiset(initializer_list<value_type> il, const Allocator& a)
|
| 1144 |
: multiset(il, Compare(), a) { }
|
| 1145 |
~multiset();
|
| 1146 |
multiset& operator=(const multiset& x);
|
| 1147 |
+
multiset& operator=(multiset&& x)
|
| 1148 |
+
noexcept(allocator_traits<Allocator>::is_always_equal::value &&
|
| 1149 |
+
is_nothrow_move_assignable_v<Compare>);
|
| 1150 |
multiset& operator=(initializer_list<value_type>);
|
| 1151 |
allocator_type get_allocator() const noexcept;
|
| 1152 |
|
| 1153 |
// iterators:
|
| 1154 |
iterator begin() noexcept;
|
|
|
|
| 1180 |
iterator insert(const_iterator position, value_type&& x);
|
| 1181 |
template <class InputIterator>
|
| 1182 |
void insert(InputIterator first, InputIterator last);
|
| 1183 |
void insert(initializer_list<value_type>);
|
| 1184 |
|
| 1185 |
+
node_type extract(const_iterator position);
|
| 1186 |
+
node_type extract(const key_type& x);
|
| 1187 |
+
iterator insert(node_type&& nh);
|
| 1188 |
+
iterator insert(const_iterator hint, node_type&& nh);
|
| 1189 |
+
|
| 1190 |
+
iterator erase(iterator position);
|
| 1191 |
iterator erase(const_iterator position);
|
| 1192 |
size_type erase(const key_type& x);
|
| 1193 |
iterator erase(const_iterator first, const_iterator last);
|
| 1194 |
+
void swap(multiset&)
|
| 1195 |
+
noexcept(allocator_traits<Allocator>::is_always_equal::value &&
|
| 1196 |
+
is_nothrow_swappable_v<Compare>);
|
| 1197 |
void clear() noexcept;
|
| 1198 |
|
| 1199 |
+
template<class C2>
|
| 1200 |
+
void merge(multiset<Key, C2, Allocator>& source);
|
| 1201 |
+
template<class C2>
|
| 1202 |
+
void merge(multiset<Key, C2, Allocator>&& source);
|
| 1203 |
+
template<class C2>
|
| 1204 |
+
void merge(set<Key, C2, Allocator>& source);
|
| 1205 |
+
template<class C2>
|
| 1206 |
+
void merge(set<Key, C2, Allocator>&& source);
|
| 1207 |
+
|
| 1208 |
// observers:
|
| 1209 |
key_compare key_comp() const;
|
| 1210 |
value_compare value_comp() const;
|
| 1211 |
|
| 1212 |
// set operations:
|
|
|
|
| 1234 |
pair<iterator, iterator> equal_range(const K& x);
|
| 1235 |
template <class K>
|
| 1236 |
pair<const_iterator, const_iterator> equal_range(const K& x) const;
|
| 1237 |
};
|
| 1238 |
|
| 1239 |
+
template<class InputIterator,
|
| 1240 |
+
class Compare = less<typename iterator_traits<InputIterator>::value_type>,
|
| 1241 |
+
class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>>
|
| 1242 |
+
multiset(InputIterator, InputIterator,
|
| 1243 |
+
Compare = Compare(), Allocator = Allocator())
|
| 1244 |
+
-> multiset<typename iterator_traits<InputIterator>::value_type, Compare, Allocator>;
|
| 1245 |
+
|
| 1246 |
+
template<class Key, class Compare = less<Key>, class Allocator = allocator<Key>>
|
| 1247 |
+
multiset(initializer_list<Key>, Compare = Compare(), Allocator = Allocator())
|
| 1248 |
+
-> multiset<Key, Compare, Allocator>;
|
| 1249 |
+
|
| 1250 |
+
template<class InputIterator, class Allocator>
|
| 1251 |
+
multiset(InputIterator, InputIterator, Allocator)
|
| 1252 |
+
-> multiset<typename iterator_traits<InputIterator>::value_type,
|
| 1253 |
+
less<typename iterator_traits<InputIterator>::value_type>, Allocator>;
|
| 1254 |
+
|
| 1255 |
+
template<class Key, class Allocator>
|
| 1256 |
+
multiset(initializer_list<Key>, Allocator) -> multiset<Key, less<Key>, Allocator>;
|
| 1257 |
+
|
| 1258 |
template <class Key, class Compare, class Allocator>
|
| 1259 |
bool operator==(const multiset<Key, Compare, Allocator>& x,
|
| 1260 |
const multiset<Key, Compare, Allocator>& y);
|
| 1261 |
template <class Key, class Compare, class Allocator>
|
| 1262 |
bool operator< (const multiset<Key, Compare, Allocator>& x,
|
|
|
|
| 1272 |
const multiset<Key, Compare, Allocator>& y);
|
| 1273 |
template <class Key, class Compare, class Allocator>
|
| 1274 |
bool operator<=(const multiset<Key, Compare, Allocator>& x,
|
| 1275 |
const multiset<Key, Compare, Allocator>& y);
|
| 1276 |
|
| 1277 |
+
// [multiset.special], specialized algorithms
|
| 1278 |
template <class Key, class Compare, class Allocator>
|
| 1279 |
void swap(multiset<Key, Compare, Allocator>& x,
|
| 1280 |
+
multiset<Key, Compare, Allocator>& y)
|
| 1281 |
+
noexcept(noexcept(x.swap(y)));
|
| 1282 |
}
|
| 1283 |
```
|
| 1284 |
|
| 1285 |
#### `multiset` constructors <a id="multiset.cons">[[multiset.cons]]</a>
|
| 1286 |
|
| 1287 |
``` cpp
|
| 1288 |
+
explicit multiset(const Compare& comp, const Allocator& = Allocator());
|
|
|
|
| 1289 |
```
|
| 1290 |
|
| 1291 |
+
*Effects:* Constructs an empty `multiset` using the specified comparison
|
| 1292 |
+
object and allocator.
|
| 1293 |
|
| 1294 |
*Complexity:* Constant.
|
| 1295 |
|
| 1296 |
``` cpp
|
| 1297 |
template <class InputIterator>
|
| 1298 |
multiset(InputIterator first, InputIterator last,
|
| 1299 |
const Compare& comp = Compare(), const Allocator& = Allocator());
|
| 1300 |
```
|
| 1301 |
|
|
|
|
|
|
|
|
|
|
| 1302 |
*Effects:* Constructs an empty `multiset` using the specified comparison
|
| 1303 |
object and allocator, and inserts elements from the range \[`first`,
|
| 1304 |
`last`).
|
| 1305 |
|
| 1306 |
*Complexity:* Linear in N if the range \[`first`, `last`) is already
|
|
|
|
| 1309 |
#### `multiset` specialized algorithms <a id="multiset.special">[[multiset.special]]</a>
|
| 1310 |
|
| 1311 |
``` cpp
|
| 1312 |
template <class Key, class Compare, class Allocator>
|
| 1313 |
void swap(multiset<Key, Compare, Allocator>& x,
|
| 1314 |
+
multiset<Key, Compare, Allocator>& y)
|
| 1315 |
+
noexcept(noexcept(x.swap(y)));
|
| 1316 |
```
|
| 1317 |
|
| 1318 |
+
*Effects:* As if by `x.swap(y)`.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1319 |
|