- tmp/tmpyqgk4xlt/{from.md → to.md} +583 -504
tmp/tmpyqgk4xlt/{from.md → to.md}
RENAMED
|
@@ -50,15 +50,16 @@ function and destroyed using the
|
|
| 50 |
container’s element type, not for internal types used by the container.
|
| 51 |
This means, for example, that a node-based container might need to
|
| 52 |
construct nodes containing aligned buffers and call `construct` to place
|
| 53 |
the element into the buffer.
|
| 54 |
|
| 55 |
-
In Tables [[tab:containers.container.requirements]]
|
| 56 |
-
[[tab:containers.reversible.requirements]],
|
| 57 |
-
|
| 58 |
-
`
|
| 59 |
-
`
|
|
|
|
| 60 |
|
| 61 |
Notes: the algorithm `equal()` is defined in Clause [[algorithms]].
|
| 62 |
Those entries marked “(Note A)” or “(Note B)” have linear complexity for
|
| 63 |
`array` and have constant complexity for all other standard containers.
|
| 64 |
|
|
@@ -70,28 +71,44 @@ constructors, inserts, and erases.
|
|
| 70 |
|
| 71 |
returns an iterator referring to the first element in the container.
|
| 72 |
`end()` returns an iterator which is the past-the-end value for the
|
| 73 |
container. If the container is empty, then `begin() == end()`;
|
| 74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
Unless otherwise specified, all containers defined in this clause obtain
|
| 76 |
memory using an allocator (see [[allocator.requirements]]). Copy
|
| 77 |
constructors for these container types obtain an allocator by calling
|
| 78 |
`allocator_traits<allocator_type>::select_on_container_copy_construction`
|
| 79 |
-
on
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
allocator only if
|
| 93 |
`allocator_traits<allocator_type>::propagate_on_container_copy_assignment::value`,
|
| 94 |
`allocator_traits<allocator_type>::propagate_on_container_move_assignment::value`,
|
| 95 |
or
|
| 96 |
`allocator_traits<allocator_type>::propagate_on_container_swap::value`
|
| 97 |
is true within the implementation of the corresponding container
|
|
@@ -130,12 +147,13 @@ Unless otherwise specified (see [[associative.reqmts.except]],
|
|
| 130 |
container types defined in this Clause meet the following additional
|
| 131 |
requirements:
|
| 132 |
|
| 133 |
- if an exception is thrown by an `insert()` or `emplace()` function
|
| 134 |
while inserting a single element, that function has no effects.
|
| 135 |
-
- if an exception is thrown by a `push_back()`
|
| 136 |
-
function, that function has no
|
|
|
|
| 137 |
- no `erase()`, `clear()`, `pop_back()` or `pop_front()` function throws
|
| 138 |
an exception.
|
| 139 |
- no copy constructor or assignment operator of a returned iterator
|
| 140 |
throws an exception.
|
| 141 |
- no `swap()` function throws an exception.
|
|
@@ -163,29 +181,56 @@ All of the containers defined in this Clause and in ([[basic.string]])
|
|
| 163 |
except `array` meet the additional requirements of an allocator-aware
|
| 164 |
container, as described in Table [[tab:containers.allocatoraware]].
|
| 165 |
|
| 166 |
Given a container type `X` having an `allocator_type` identical to `A`
|
| 167 |
and a `value_type` identical to `T` and given an lvalue `m` of type `A`,
|
| 168 |
-
a pointer `p` of type `T*`, an expression `v` of type
|
| 169 |
-
`rv` of type `T`, the following terms are defined.
|
| 170 |
-
allocator-aware, the terms below are defined as if `A` were
|
| 171 |
-
`std::allocator<T>`
|
|
|
|
| 172 |
|
| 173 |
-
- `T` is *`
|
| 174 |
-
is well-formed:
|
| 175 |
``` cpp
|
| 176 |
-
allocator_traits<A>::construct(m, p
|
| 177 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 178 |
- `T` is *`MoveInsertable` into `X`* means that the following expression
|
| 179 |
is well-formed:
|
| 180 |
``` cpp
|
| 181 |
-
allocator_traits<A>::construct(m, p, rv)
|
| 182 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 183 |
- `T` is *`EmplaceConstructible` into `X` from `args`*, for zero or more
|
| 184 |
arguments `args`, means that the following expression is well-formed:
|
| 185 |
``` cpp
|
| 186 |
-
allocator_traits<A>::construct(m, p, args)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 187 |
```
|
| 188 |
|
| 189 |
A container calls `allocator_traits<A>::construct(m, p, args)` to
|
| 190 |
construct an element at `p` using `args`. The default `construct` in
|
| 191 |
`std::allocator` will call `::new((void*)p) T(args)`, but specialized
|
|
@@ -193,12 +238,12 @@ allocators may choose a different definition.
|
|
| 193 |
|
| 194 |
In Table [[tab:containers.allocatoraware]], `X` denotes an
|
| 195 |
allocator-aware container class with a `value_type` of `T` using
|
| 196 |
allocator of type `A`, `u` denotes a variable, `a` and `b` denote
|
| 197 |
non-const lvalues of type `X`, `t` denotes an lvalue or a const rvalue
|
| 198 |
-
of type X`
|
| 199 |
-
of type `A`
|
| 200 |
|
| 201 |
### Container data races <a id="container.requirements.dataraces">[[container.requirements.dataraces]]</a>
|
| 202 |
|
| 203 |
For purposes of avoiding data races ([[res.on.data.races]]),
|
| 204 |
implementations shall consider the following functions to be `const`:
|
|
@@ -206,11 +251,11 @@ implementations shall consider the following functions to be `const`:
|
|
| 206 |
`lower_bound`, `upper_bound`, `equal_range`, `at` and, except in
|
| 207 |
associative or unordered associative containers, `operator[]`.
|
| 208 |
|
| 209 |
Notwithstanding ([[res.on.data.races]]), implementations are required
|
| 210 |
to avoid data races when the contents of the contained object in
|
| 211 |
-
different elements in the same
|
| 212 |
modified concurrently.
|
| 213 |
|
| 214 |
For a `vector<int> x` with a size greater than one, `x[1] = 5` and
|
| 215 |
`*x.begin() = 10` can be executed concurrently without a data race, but
|
| 216 |
`x[0] = 5` and `*x.begin() = 10` executed concurrently may result in a
|
|
@@ -269,12 +314,12 @@ The iterator returned from `a.insert(p, n, t)` points to the copy of the
|
|
| 269 |
first element inserted into `a`, or `p` if `n == 0`.
|
| 270 |
|
| 271 |
The iterator returned from `a.insert(p, i, j)` points to the copy of the
|
| 272 |
first element inserted into `a`, or `p` if `i == j`.
|
| 273 |
|
| 274 |
-
The iterator returned from `a.insert(p,
|
| 275 |
-
first element inserted into `a`, or `p` if `
|
| 276 |
|
| 277 |
The iterator returned from `a.emplace(p, args)` points to the new
|
| 278 |
element constructed from `args` into `a`.
|
| 279 |
|
| 280 |
The iterator returned from `a.erase(q)` points to the element
|
|
@@ -334,12 +379,12 @@ library provides four basic kinds of associative containers: `set`,
|
|
| 334 |
`multiset`, `map` and `multimap`.
|
| 335 |
|
| 336 |
Each associative container is parameterized on `Key` and an ordering
|
| 337 |
relation `Compare` that induces a strict weak ordering (
|
| 338 |
[[alg.sorting]]) on elements of `Key`. In addition, `map` and `multimap`
|
| 339 |
-
associate an arbitrary type `T` with the `Key`. The object of
|
| 340 |
-
`Compare` is called the *comparison object* of a container.
|
| 341 |
|
| 342 |
The phrase “equivalence of keys” means the equivalence relation imposed
|
| 343 |
by the comparison and *not* the `operator==` on keys. That is, two keys
|
| 344 |
`k1` and `k2` are considered to be equivalent if for the comparison
|
| 345 |
object `comp`, `comp(k1, k2) == false && comp(k2, k1) == false`. For any
|
|
@@ -352,12 +397,11 @@ The `set` and `map` classes support unique keys; the `multiset` and
|
|
| 352 |
`multimap` classes support equivalent keys. For `multiset` and
|
| 353 |
`multimap`, `insert`, `emplace`, and `erase` preserve the relative
|
| 354 |
ordering of equivalent elements.
|
| 355 |
|
| 356 |
For `set` and `multiset` the value type is the same as the key type. For
|
| 357 |
-
`map` and `multimap` it is equal to `pair<const Key, T>`.
|
| 358 |
-
associative container are immutable.
|
| 359 |
|
| 360 |
`iterator`
|
| 361 |
|
| 362 |
of an associative container is of the bidirectional iterator category.
|
| 363 |
For associative containers where the value type is the same as the key
|
|
@@ -378,24 +422,31 @@ associated `value_type`, `pair<const key_type, mapped_type>`, is not
|
|
| 378 |
`CopyAssignable`.
|
| 379 |
|
| 380 |
In Table [[tab:containers.associative.requirements]], `X` denotes an
|
| 381 |
associative container class, `a` denotes a value of `X`, `a_uniq`
|
| 382 |
denotes a value of `X` when `X` supports unique keys, `a_eq` denotes a
|
| 383 |
-
value of `X` when `X` supports multiple keys, `
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
`
|
| 390 |
-
`
|
| 391 |
-
`
|
| 392 |
-
|
| 393 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 394 |
|
| 395 |
The `insert` and `emplace` members shall not affect the validity of
|
| 396 |
-
iterators and references to the container, and the erase members shall
|
| 397 |
invalidate only iterators and references to the erased elements.
|
| 398 |
|
| 399 |
The fundamental property of iterators of associative containers is that
|
| 400 |
they iterate through the containers in the non-descending order of keys
|
| 401 |
where non-descending is defined by the comparison that was used to
|
|
@@ -419,10 +470,15 @@ passed object, even if that object is passed by reference. When an
|
|
| 419 |
associative container is copied, either through a copy constructor or an
|
| 420 |
assignment operator, the target container shall then use the comparison
|
| 421 |
object from the container being copied, as if that comparison object had
|
| 422 |
been passed to the target container in its constructor.
|
| 423 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 424 |
#### Exception safety guarantees <a id="associative.reqmts.except">[[associative.reqmts.except]]</a>
|
| 425 |
|
| 426 |
For associative containers, no `clear()` function throws an exception.
|
| 427 |
`erase(k)` does not throw an exception unless that exception is thrown
|
| 428 |
by the container’s `Compare` object (if any).
|
|
@@ -454,19 +510,24 @@ function object type `Hash` that meets the `Hash` requirements (
|
|
| 454 |
of type `Key`, and by a binary predicate `Pred` that induces an
|
| 455 |
equivalence relation on values of type `Key`. Additionally,
|
| 456 |
`unordered_map` and `unordered_multimap` associate an arbitrary *mapped
|
| 457 |
type* `T` with the `Key`.
|
| 458 |
|
| 459 |
-
|
| 460 |
-
|
|
|
|
|
|
|
| 461 |
|
| 462 |
Two values `k1` and `k2` of type `Key` are considered equivalent if the
|
| 463 |
-
container’s
|
| 464 |
-
values. If `k1` and `k2` are equivalent, the hash function
|
| 465 |
-
the same value for both. Thus, when an unordered
|
| 466 |
-
is instantiated with a non-default `Pred`
|
| 467 |
-
non-default `Hash` parameter as well.
|
|
|
|
|
|
|
|
|
|
| 468 |
|
| 469 |
An unordered associative container supports *unique keys* if it may
|
| 470 |
contain at most one element for each key. Otherwise, it supports
|
| 471 |
*equivalent keys*. `unordered_set` and `unordered_map` support unique
|
| 472 |
keys. `unordered_multiset` and `unordered_multimap` support equivalent
|
|
@@ -482,10 +543,18 @@ unless otherwise specified.
|
|
| 482 |
For `unordered_set` and `unordered_multiset` the value type is the same
|
| 483 |
as the key type. For `unordered_map` and `unordered_multimap` it is
|
| 484 |
`std::pair<const Key,
|
| 485 |
T>`.
|
| 486 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 487 |
The elements of an unordered associative container are organized into
|
| 488 |
*buckets*. Keys with the same hash code appear in the same bucket. The
|
| 489 |
number of buckets is automatically increased as elements are added to an
|
| 490 |
unordered associative container, so that the average number of elements
|
| 491 |
per bucket is kept below a bound. Rehashing invalidates iterators,
|
|
@@ -520,15 +589,14 @@ type `float`.
|
|
| 520 |
|
| 521 |
Two unordered containers `a` and `b` compare equal if
|
| 522 |
`a.size() == b.size()` and, for every equivalent-key group \[`Ea1`,
|
| 523 |
`Ea2`) obtained from `a.equal_range(Ea1)`, there exists an
|
| 524 |
equivalent-key group \[`Eb1`, `Eb2`) obtained from `b.equal_range(Ea1)`,
|
| 525 |
-
such that `
|
| 526 |
-
`
|
| 527 |
-
|
| 528 |
-
|
| 529 |
-
returned by `key_equal()`, and to the hasher returned by
|
| 530 |
`hash_function()`) is proportional to N in the average case and to N² in
|
| 531 |
the worst case, where N is a.size(). For `unordered_multiset` and
|
| 532 |
`unordered_multimap`, the complexity of `operator==` is proportional to
|
| 533 |
$\sum E_i^2$ in the average case and to N² in the worst case, where N is
|
| 534 |
`a.size()`, and Eᵢ is the size of the iᵗʰ equivalent-key group in `a`.
|
|
@@ -550,12 +618,13 @@ associative container are of at least the forward iterator category. For
|
|
| 550 |
unordered associative containers where the key type and value type are
|
| 551 |
the same, both `iterator` and `const_iterator` are const iterators.
|
| 552 |
|
| 553 |
The `insert` and `emplace` members shall not affect the validity of
|
| 554 |
references to container elements, but may invalidate all iterators to
|
| 555 |
-
the container. The erase members shall invalidate only iterators and
|
| 556 |
-
references to the erased elements
|
|
|
|
| 557 |
|
| 558 |
The `insert` and `emplace` members shall not affect the validity of
|
| 559 |
iterators if `(N+n) < z * B`, where `N` is the number of elements in the
|
| 560 |
container prior to the insert operation, `n` is the number of elements
|
| 561 |
inserted, `B` is the container’s bucket count, and `z` is the
|
|
@@ -619,15 +688,15 @@ namespace std {
|
|
| 619 |
template <class T, size_t N>
|
| 620 |
struct tuple_size<array<T, N> >;
|
| 621 |
template <size_t I, class T, size_t N>
|
| 622 |
struct tuple_element<I, array<T, N> >;
|
| 623 |
template <size_t I, class T, size_t N>
|
| 624 |
-
T& get(array<T, N>&) noexcept;
|
| 625 |
template <size_t I, class T, size_t N>
|
| 626 |
-
T&& get(array<T, N>&&) noexcept;
|
| 627 |
template <size_t I, class T, size_t N>
|
| 628 |
-
const T& get(const array<T, N>&) noexcept;
|
| 629 |
}
|
| 630 |
```
|
| 631 |
|
| 632 |
\synopsis{Header \texttt{\<deque\>} synopsis}
|
| 633 |
|
|
@@ -726,10 +795,11 @@ namespace std {
|
|
| 726 |
template <class Allocator> class vector<bool,Allocator>;
|
| 727 |
|
| 728 |
// hash support
|
| 729 |
template <class T> struct hash;
|
| 730 |
template <class Allocator> struct hash<vector<bool, Allocator> >;
|
|
|
|
| 731 |
```
|
| 732 |
|
| 733 |
### Class template `array` <a id="array">[[array]]</a>
|
| 734 |
|
| 735 |
#### Class template `array` overview <a id="array.overview">[[array.overview]]</a>
|
|
@@ -772,12 +842,12 @@ namespace std {
|
|
| 772 |
typedef size_t size_type;
|
| 773 |
typedef ptrdiff_t difference_type;
|
| 774 |
typedef T value_type;
|
| 775 |
typedef T* pointer;
|
| 776 |
typedef const T* const_pointer;
|
| 777 |
-
typedef reverse_iterator<iterator>
|
| 778 |
-
typedef reverse_iterator<const_iterator>
|
| 779 |
|
| 780 |
T elems[N]; // exposition only
|
| 781 |
|
| 782 |
// no explicit construct/copy/destroy for aggregate type
|
| 783 |
|
|
@@ -799,23 +869,23 @@ namespace std {
|
|
| 799 |
const_iterator cend() const noexcept;
|
| 800 |
const_reverse_iterator crbegin() const noexcept;
|
| 801 |
const_reverse_iterator crend() const noexcept;
|
| 802 |
|
| 803 |
// capacity:
|
| 804 |
-
constexpr size_type size() noexcept;
|
| 805 |
-
constexpr size_type max_size() noexcept;
|
| 806 |
-
constexpr bool empty() noexcept;
|
| 807 |
|
| 808 |
// element access:
|
| 809 |
reference operator[](size_type n);
|
| 810 |
-
const_reference operator[](size_type n) const;
|
| 811 |
-
const_reference at(size_type n) const;
|
| 812 |
reference at(size_type n);
|
|
|
|
| 813 |
reference front();
|
| 814 |
-
const_reference front() const;
|
| 815 |
reference back();
|
| 816 |
-
const_reference back() const;
|
| 817 |
|
| 818 |
T * data() noexcept;
|
| 819 |
const T * data() const noexcept;
|
| 820 |
};
|
| 821 |
}
|
|
@@ -846,16 +916,16 @@ template <class T, size_t N> void swap(array<T,N>& x, array<T,N>& y) noexcept(no
|
|
| 846 |
|
| 847 |
``` cpp
|
| 848 |
x.swap(y);
|
| 849 |
```
|
| 850 |
|
| 851 |
-
*Complexity:*
|
| 852 |
|
| 853 |
#### `array::size` <a id="array.size">[[array.size]]</a>
|
| 854 |
|
| 855 |
``` cpp
|
| 856 |
-
template <class T, size_t N> constexpr size_type array<T,N>::size() noexcept;
|
| 857 |
```
|
| 858 |
|
| 859 |
*Returns:* `N`
|
| 860 |
|
| 861 |
#### `array::data` <a id="array.data">[[array.data]]</a>
|
|
@@ -884,11 +954,11 @@ void swap(array& y) noexcept(noexcept(swap(declval<T&>(), declval<T&>())));
|
|
| 884 |
*Effects:* `swap_ranges(begin(), end(), y.begin())`
|
| 885 |
|
| 886 |
*Throws:* Nothing unless one of the element-wise swap calls throws an
|
| 887 |
exception.
|
| 888 |
|
| 889 |
-
*Note:* Unlike the `swap` function for other containers, array::swap
|
| 890 |
takes linear time, may exit via an exception, and does not cause
|
| 891 |
iterators to become associated with the other container.
|
| 892 |
|
| 893 |
#### Zero sized arrays <a id="array.zero">[[array.zero]]</a>
|
| 894 |
|
|
@@ -904,42 +974,43 @@ Member function `swap()` shall have a *noexcept-specification* which is
|
|
| 904 |
equivalent to `noexcept(true)`.
|
| 905 |
|
| 906 |
#### Tuple interface to class template `array` <a id="array.tuple">[[array.tuple]]</a>
|
| 907 |
|
| 908 |
``` cpp
|
| 909 |
-
|
|
|
|
|
|
|
| 910 |
```
|
| 911 |
|
| 912 |
-
*Return type:* integral constant expression.
|
| 913 |
-
|
| 914 |
-
*Value:* `N`
|
| 915 |
-
|
| 916 |
``` cpp
|
| 917 |
tuple_element<I, array<T, N> >::type
|
| 918 |
```
|
| 919 |
|
| 920 |
*Requires:* `I < N`. The program is ill-formed if `I` is out of bounds.
|
| 921 |
|
| 922 |
*Value:* The type T.
|
| 923 |
|
| 924 |
``` cpp
|
| 925 |
-
template <size_t I, class T, size_t N>
|
|
|
|
| 926 |
```
|
| 927 |
|
| 928 |
*Requires:* `I < N`. The program is ill-formed if `I` is out of bounds.
|
| 929 |
|
| 930 |
*Returns:* A reference to the `I`th element of `a`, where indexing is
|
| 931 |
zero-based.
|
| 932 |
|
| 933 |
``` cpp
|
| 934 |
-
template <size_t I, class T, size_t N>
|
|
|
|
| 935 |
```
|
| 936 |
|
| 937 |
*Effects:* Equivalent to `return std::move(get<I>(a));`
|
| 938 |
|
| 939 |
``` cpp
|
| 940 |
-
template <size_t I, class T, size_t N>
|
|
|
|
| 941 |
```
|
| 942 |
|
| 943 |
*Requires:* `I < N`. The program is ill-formed if `I` is out of bounds.
|
| 944 |
|
| 945 |
*Returns:* A const reference to the `I`th element of `a`, where indexing
|
|
@@ -983,12 +1054,13 @@ namespace std {
|
|
| 983 |
typedef typename allocator_traits<Allocator>::const_pointer const_pointer;
|
| 984 |
typedef std::reverse_iterator<iterator> reverse_iterator;
|
| 985 |
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
| 986 |
|
| 987 |
// [deque.cons], construct/copy/destroy:
|
| 988 |
-
|
| 989 |
-
explicit deque(
|
|
|
|
| 990 |
deque(size_type n, const T& value, const Allocator& = Allocator());
|
| 991 |
template <class InputIterator>
|
| 992 |
deque(InputIterator first, InputIterator last, const Allocator& = Allocator());
|
| 993 |
deque(const deque& x);
|
| 994 |
deque(deque&&);
|
|
@@ -1085,24 +1157,25 @@ namespace std {
|
|
| 1085 |
```
|
| 1086 |
|
| 1087 |
#### `deque` constructors, copy, and assignment <a id="deque.cons">[[deque.cons]]</a>
|
| 1088 |
|
| 1089 |
``` cpp
|
| 1090 |
-
explicit deque(const Allocator&
|
| 1091 |
```
|
| 1092 |
|
| 1093 |
*Effects:* Constructs an empty `deque`, using the specified allocator.
|
| 1094 |
|
| 1095 |
*Complexity:* Constant.
|
| 1096 |
|
| 1097 |
``` cpp
|
| 1098 |
-
explicit deque(size_type n);
|
| 1099 |
```
|
| 1100 |
|
| 1101 |
-
*Effects:* Constructs a `deque` with `n`
|
|
|
|
| 1102 |
|
| 1103 |
-
*Requires:* `T` shall be `
|
| 1104 |
|
| 1105 |
*Complexity:* Linear in `n`.
|
| 1106 |
|
| 1107 |
``` cpp
|
| 1108 |
deque(size_type n, const T& value,
|
|
@@ -1123,71 +1196,46 @@ template <class InputIterator>
|
|
| 1123 |
```
|
| 1124 |
|
| 1125 |
*Effects:* Constructs a `deque` equal to the range \[`first`, `last`),
|
| 1126 |
using the specified allocator.
|
| 1127 |
|
| 1128 |
-
*Complexity:* `distance(first, last)`.
|
| 1129 |
-
|
| 1130 |
-
``` cpp
|
| 1131 |
-
template <class InputIterator>
|
| 1132 |
-
void assign(InputIterator first, InputIterator last);
|
| 1133 |
-
```
|
| 1134 |
-
|
| 1135 |
-
*Effects:*
|
| 1136 |
-
|
| 1137 |
-
``` cpp
|
| 1138 |
-
erase(begin(), end());
|
| 1139 |
-
insert(begin(), first, last);
|
| 1140 |
-
```
|
| 1141 |
-
|
| 1142 |
-
``` cpp
|
| 1143 |
-
void assign(size_type n, const T& t);
|
| 1144 |
-
```
|
| 1145 |
-
|
| 1146 |
-
*Effects:*
|
| 1147 |
-
|
| 1148 |
-
``` cpp
|
| 1149 |
-
erase(begin(), end());
|
| 1150 |
-
insert(begin(), n, t);
|
| 1151 |
-
```
|
| 1152 |
|
| 1153 |
#### `deque` capacity <a id="deque.capacity">[[deque.capacity]]</a>
|
| 1154 |
|
| 1155 |
``` cpp
|
| 1156 |
void resize(size_type sz);
|
| 1157 |
```
|
| 1158 |
|
| 1159 |
-
*Effects:* If `sz <= size()`, equivalent to
|
| 1160 |
-
`
|
| 1161 |
-
|
| 1162 |
|
| 1163 |
-
*Requires:* `T` shall be `
|
|
|
|
| 1164 |
|
| 1165 |
``` cpp
|
| 1166 |
void resize(size_type sz, const T& c);
|
| 1167 |
```
|
| 1168 |
|
| 1169 |
-
*Effects:*
|
| 1170 |
-
|
| 1171 |
-
``
|
| 1172 |
-
if (sz > size())
|
| 1173 |
-
insert(end(), sz-size(), c);
|
| 1174 |
-
else if (sz < size())
|
| 1175 |
-
erase(begin()+sz, end());
|
| 1176 |
-
else
|
| 1177 |
-
; // do nothing
|
| 1178 |
-
```
|
| 1179 |
|
| 1180 |
*Requires:* `T` shall be `CopyInsertable` into `*this`.
|
| 1181 |
|
| 1182 |
``` cpp
|
| 1183 |
void shrink_to_fit();
|
| 1184 |
```
|
| 1185 |
|
| 1186 |
-
*
|
| 1187 |
-
|
| 1188 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1189 |
|
| 1190 |
#### `deque` modifiers <a id="deque.modifiers">[[deque.modifiers]]</a>
|
| 1191 |
|
| 1192 |
``` cpp
|
| 1193 |
iterator insert(const_iterator position, const T& x);
|
|
@@ -1212,12 +1260,14 @@ iterators and references to elements of the deque. An insertion at
|
|
| 1212 |
either end of the deque invalidates all the iterators to the deque, but
|
| 1213 |
has no effect on the validity of references to elements of the deque.
|
| 1214 |
|
| 1215 |
*Remarks:* If an exception is thrown other than by the copy constructor,
|
| 1216 |
move constructor, assignment operator, or move assignment operator of
|
| 1217 |
-
`T` there are no effects. If an exception is thrown
|
| 1218 |
-
|
|
|
|
|
|
|
| 1219 |
|
| 1220 |
*Complexity:* The complexity is linear in the number of elements
|
| 1221 |
inserted plus the lesser of the distances to the beginning and end of
|
| 1222 |
the deque. Inserting a single element either at the beginning or end of
|
| 1223 |
a deque always takes constant time and causes a single call to a
|
|
@@ -1271,23 +1321,23 @@ access to list elements is not supported. It is intended that
|
|
| 1271 |
hand-written C-style singly linked list. Features that would conflict
|
| 1272 |
with that goal have been omitted.
|
| 1273 |
|
| 1274 |
A `forward_list` satisfies all of the requirements of a container
|
| 1275 |
(Table [[tab:containers.container.requirements]]), except that the
|
| 1276 |
-
`size()` member function is not provided
|
| 1277 |
-
satisfies all of the requirements for
|
| 1278 |
-
(Table [[tab:containers.allocatoraware]]).
|
| 1279 |
-
`forward_list` provides the `assign` member functions
|
| 1280 |
-
[[tab:containers.sequence.requirements]]) and several of the
|
| 1281 |
-
container requirements (Table
|
| 1282 |
-
Descriptions are provided here
|
| 1283 |
-
|
| 1284 |
-
additional semantic information.
|
| 1285 |
|
| 1286 |
Modifying any list requires access to the element preceding the first
|
| 1287 |
element of interest, but in a `forward_list` there is no constant-time
|
| 1288 |
-
way to
|
| 1289 |
modified, such as those supplied to `erase` and `splice`, must be open
|
| 1290 |
at the beginning.
|
| 1291 |
|
| 1292 |
``` cpp
|
| 1293 |
namespace std {
|
|
@@ -1305,12 +1355,13 @@ namespace std {
|
|
| 1305 |
typedef Allocator allocator_type;
|
| 1306 |
typedef typename allocator_traits<Allocator>::pointer pointer;
|
| 1307 |
typedef typename allocator_traits<Allocator>::const_pointer const_pointer;
|
| 1308 |
|
| 1309 |
// [forwardlist.cons], construct/copy/destroy:
|
| 1310 |
-
|
| 1311 |
-
explicit forward_list(
|
|
|
|
| 1312 |
forward_list(size_type n, const T& value,
|
| 1313 |
const Allocator& = Allocator());
|
| 1314 |
template <class InputIterator>
|
| 1315 |
forward_list(InputIterator first, InputIterator last,
|
| 1316 |
const Allocator& = Allocator());
|
|
@@ -1422,26 +1473,26 @@ namespace std {
|
|
| 1422 |
```
|
| 1423 |
|
| 1424 |
#### `forward_list` constructors, copy, assignment <a id="forwardlist.cons">[[forwardlist.cons]]</a>
|
| 1425 |
|
| 1426 |
``` cpp
|
| 1427 |
-
explicit forward_list(const Allocator&
|
| 1428 |
```
|
| 1429 |
|
| 1430 |
*Effects:* Constructs an empty `forward_list` object using the specified
|
| 1431 |
allocator.
|
| 1432 |
|
| 1433 |
*Complexity:* Constant.
|
| 1434 |
|
| 1435 |
``` cpp
|
| 1436 |
-
explicit forward_list(size_type n);
|
| 1437 |
```
|
| 1438 |
|
| 1439 |
-
*Effects:* Constructs a `forward_list` object with `n`
|
| 1440 |
-
elements.
|
| 1441 |
|
| 1442 |
-
*Requires:* `T` shall be `
|
| 1443 |
|
| 1444 |
*Complexity:* Linear in `n`.
|
| 1445 |
|
| 1446 |
``` cpp
|
| 1447 |
forward_list(size_type n, const T& value, const Allocator& = Allocator());
|
|
@@ -1462,23 +1513,10 @@ template <class InputIterator>
|
|
| 1462 |
*Effects:* Constructs a `forward_list` object equal to the range
|
| 1463 |
\[`first`, `last`).
|
| 1464 |
|
| 1465 |
*Complexity:* Linear in `distance(first, last)`.
|
| 1466 |
|
| 1467 |
-
``` cpp
|
| 1468 |
-
template <class InputIterator>
|
| 1469 |
-
void assign(InputIterator first, InputIterator last);
|
| 1470 |
-
```
|
| 1471 |
-
|
| 1472 |
-
*Effects:* `clear(); insert_after(before_begin(), first, last);`
|
| 1473 |
-
|
| 1474 |
-
``` cpp
|
| 1475 |
-
void assign(size_type n, const T& t);
|
| 1476 |
-
```
|
| 1477 |
-
|
| 1478 |
-
*Effects:* `clear(); insert_after(before_begin(), n, t);`
|
| 1479 |
-
|
| 1480 |
#### `forward_list` iterators <a id="forwardlist.iter">[[forwardlist.iter]]</a>
|
| 1481 |
|
| 1482 |
``` cpp
|
| 1483 |
iterator before_begin() noexcept;
|
| 1484 |
const_iterator before_begin() const noexcept;
|
|
@@ -1577,11 +1615,11 @@ iterator insert_after(const_iterator position, initializer_list<T> il);
|
|
| 1577 |
```
|
| 1578 |
|
| 1579 |
*Effects:* `insert_after(p, il.begin(), il.end())`.
|
| 1580 |
|
| 1581 |
*Returns:* An iterator pointing to the last inserted element or
|
| 1582 |
-
`position` if `
|
| 1583 |
|
| 1584 |
``` cpp
|
| 1585 |
template <class... Args>
|
| 1586 |
iterator emplace_after(const_iterator position, Args&&... args);
|
| 1587 |
```
|
|
@@ -1621,21 +1659,31 @@ dereferenceable.
|
|
| 1621 |
|
| 1622 |
*Throws:* Nothing.
|
| 1623 |
|
| 1624 |
``` cpp
|
| 1625 |
void resize(size_type sz);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1626 |
void resize(size_type sz, const value_type& c);
|
| 1627 |
```
|
| 1628 |
|
| 1629 |
*Effects:* If `sz < distance(begin(), end())`, erases the last
|
| 1630 |
`distance(begin(), end()) - sz` elements from the list. Otherwise,
|
| 1631 |
-
inserts `sz - distance(begin(), end())` elements at the end of the list
|
| 1632 |
-
|
| 1633 |
-
|
|
|
|
| 1634 |
|
| 1635 |
-
*Requires:* `T` shall be `
|
| 1636 |
-
it shall be `CopyInsertable` into `*this` for the second form.
|
| 1637 |
|
| 1638 |
``` cpp
|
| 1639 |
void clear() noexcept;
|
| 1640 |
```
|
| 1641 |
|
|
@@ -1649,11 +1697,12 @@ void clear() noexcept;
|
|
| 1649 |
void splice_after(const_iterator position, forward_list& x);
|
| 1650 |
void splice_after(const_iterator position, forward_list&& x);
|
| 1651 |
```
|
| 1652 |
|
| 1653 |
*Requires:* `position` is `before_begin()` or is a dereferenceable
|
| 1654 |
-
iterator in the range \[`begin()`, `end()`).
|
|
|
|
| 1655 |
|
| 1656 |
*Effects:* Inserts the contents of `x` after `position`, and `x` becomes
|
| 1657 |
empty. Pointers and references to the moved elements of `x` now refer to
|
| 1658 |
those same elements but as members of `*this`. Iterators referring to
|
| 1659 |
the moved elements will continue to refer to their elements, but they
|
|
@@ -1669,17 +1718,18 @@ void splice_after(const_iterator position, forward_list&& x, const_iterator i);
|
|
| 1669 |
```
|
| 1670 |
|
| 1671 |
*Requires:* `position` is `before_begin()` or is a dereferenceable
|
| 1672 |
iterator in the range \[`begin()`, `end()`). The iterator following `i`
|
| 1673 |
is a dereferenceable iterator in `x`.
|
|
|
|
| 1674 |
|
| 1675 |
*Effects:* Inserts the element following `i` into `*this`, following
|
| 1676 |
`position`, and removes it from `x`. The result is unchanged if
|
| 1677 |
-
`position == i` or `position == ++i`. Pointers and references to `*i`
|
| 1678 |
continue to refer to the same element but as a member of `*this`.
|
| 1679 |
-
Iterators to `*i`
|
| 1680 |
-
|
| 1681 |
|
| 1682 |
*Throws:* Nothing.
|
| 1683 |
|
| 1684 |
*Complexity:* 𝑂(1)
|
| 1685 |
|
|
@@ -1692,11 +1742,11 @@ void splice_after(const_iterator position, forward_list&& x,
|
|
| 1692 |
|
| 1693 |
*Requires:* `position` is `before_begin()` or is a dereferenceable
|
| 1694 |
iterator in the range \[`begin()`, `end()`). (`first`, `last`) is a
|
| 1695 |
valid range in `x`, and all iterators in the range (`first`, `last`) are
|
| 1696 |
dereferenceable. `position` is not an iterator in the range (`first`,
|
| 1697 |
-
`last`).
|
| 1698 |
|
| 1699 |
*Effects:* Inserts elements in the range (`first`, `last`) after
|
| 1700 |
`position` and removes the elements from `x`. Pointers and references to
|
| 1701 |
the moved elements of `x` now refer to those same elements but as
|
| 1702 |
members of `*this`. Iterators referring to the moved elements will
|
|
@@ -1710,18 +1760,18 @@ void remove(const T& value);
|
|
| 1710 |
template <class Predicate> void remove_if(Predicate pred);
|
| 1711 |
```
|
| 1712 |
|
| 1713 |
*Effects:* Erases all the elements in the list referred by a list
|
| 1714 |
iterator `i` for which the following conditions hold: `*i == value` (for
|
| 1715 |
-
`remove()`), `pred(*i)` is true (for `remove_if()`).
|
| 1716 |
-
|
| 1717 |
-
is the same as their relative order in the original list. Invalidates
|
| 1718 |
-
only the iterators and references to the erased elements.
|
| 1719 |
|
| 1720 |
*Throws:* Nothing unless an exception is thrown by the equality
|
| 1721 |
comparison or the predicate.
|
| 1722 |
|
|
|
|
|
|
|
| 1723 |
*Complexity:* Exactly `distance(begin(), end())` applications of the
|
| 1724 |
corresponding predicate.
|
| 1725 |
|
| 1726 |
``` cpp
|
| 1727 |
void unique();
|
|
@@ -1743,28 +1793,32 @@ comparison or the predicate.
|
|
| 1743 |
otherwise no applications of the predicate.
|
| 1744 |
|
| 1745 |
``` cpp
|
| 1746 |
void merge(forward_list& x);
|
| 1747 |
void merge(forward_list&& x);
|
| 1748 |
-
template <class Compare> void merge(forward_list& x, Compare comp)
|
| 1749 |
-
template <class Compare> void merge(forward_list&& x, Compare comp)
|
| 1750 |
```
|
| 1751 |
|
| 1752 |
*Requires:* `comp` defines a strict weak ordering ([[alg.sorting]]),
|
| 1753 |
and `*this` and `x` are both sorted according to this ordering.
|
|
|
|
| 1754 |
|
| 1755 |
-
*Effects:* Merges
|
| 1756 |
-
|
| 1757 |
-
|
| 1758 |
-
|
| 1759 |
-
|
| 1760 |
-
|
| 1761 |
-
|
| 1762 |
-
behave as iterators into `*this`, not into `x`.
|
| 1763 |
|
| 1764 |
-
*
|
| 1765 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1766 |
|
| 1767 |
``` cpp
|
| 1768 |
void sort();
|
| 1769 |
template <class Compare> void sort(Compare comp);
|
| 1770 |
```
|
|
@@ -1772,14 +1826,15 @@ template <class Compare> void sort(Compare comp);
|
|
| 1772 |
*Requires:* `operator<` (for the version with no arguments) or `comp`
|
| 1773 |
(for the version with a comparison argument) defines a strict weak
|
| 1774 |
ordering ([[alg.sorting]]).
|
| 1775 |
|
| 1776 |
*Effects:* Sorts the list according to the `operator<` or the `comp`
|
| 1777 |
-
function object.
|
| 1778 |
-
|
| 1779 |
-
|
| 1780 |
-
|
|
|
|
| 1781 |
|
| 1782 |
*Complexity:* Approximately N log N comparisons, where N is
|
| 1783 |
`distance(begin(), end())`.
|
| 1784 |
|
| 1785 |
``` cpp
|
|
@@ -1840,12 +1895,13 @@ namespace std {
|
|
| 1840 |
typedef typename allocator_traits<Allocator>::const_pointer const_pointer;
|
| 1841 |
typedef std::reverse_iterator<iterator> reverse_iterator;
|
| 1842 |
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
| 1843 |
|
| 1844 |
// [list.cons], construct/copy/destroy:
|
| 1845 |
-
|
| 1846 |
-
explicit list(
|
|
|
|
| 1847 |
list(size_type n, const T& value, const Allocator& = Allocator());
|
| 1848 |
template <class InputIterator>
|
| 1849 |
list(InputIterator first, InputIterator last, const Allocator& = Allocator());
|
| 1850 |
list(const list& x);
|
| 1851 |
list(list&& x);
|
|
@@ -1962,24 +2018,25 @@ namespace std {
|
|
| 1962 |
```
|
| 1963 |
|
| 1964 |
#### `list` constructors, copy, and assignment <a id="list.cons">[[list.cons]]</a>
|
| 1965 |
|
| 1966 |
``` cpp
|
| 1967 |
-
explicit list(const Allocator&
|
| 1968 |
```
|
| 1969 |
|
| 1970 |
*Effects:* Constructs an empty list, using the specified allocator.
|
| 1971 |
|
| 1972 |
*Complexity:* Constant.
|
| 1973 |
|
| 1974 |
``` cpp
|
| 1975 |
-
explicit list(size_type n);
|
| 1976 |
```
|
| 1977 |
|
| 1978 |
-
*Effects:* Constructs a `list` with `n`
|
|
|
|
| 1979 |
|
| 1980 |
-
*Requires:* `T` shall be `
|
| 1981 |
|
| 1982 |
*Complexity:* Linear in `n`.
|
| 1983 |
|
| 1984 |
``` cpp
|
| 1985 |
list(size_type n, const T& value,
|
|
@@ -2001,40 +2058,26 @@ list(InputIterator first, InputIterator last,
|
|
| 2001 |
|
| 2002 |
*Effects:* Constructs a `list` equal to the range \[`first`, `last`).
|
| 2003 |
|
| 2004 |
*Complexity:* Linear in `distance(first, last)`.
|
| 2005 |
|
| 2006 |
-
``` cpp
|
| 2007 |
-
template <class InputIterator>
|
| 2008 |
-
void assign(InputIterator first, InputIterator last);
|
| 2009 |
-
```
|
| 2010 |
-
|
| 2011 |
-
*Effects:* Replaces the contents of the list with the range
|
| 2012 |
-
`[first, last)`.
|
| 2013 |
-
|
| 2014 |
-
``` cpp
|
| 2015 |
-
void assign(size_type n, const T& t);
|
| 2016 |
-
```
|
| 2017 |
-
|
| 2018 |
-
*Effects:* Replaces the contents of the list with `n` copies of `t`.
|
| 2019 |
-
|
| 2020 |
#### `list` capacity <a id="list.capacity">[[list.capacity]]</a>
|
| 2021 |
|
| 2022 |
``` cpp
|
| 2023 |
void resize(size_type sz);
|
| 2024 |
```
|
| 2025 |
|
| 2026 |
-
*Effects:* If `size() < sz`, appends `sz - size()`
|
| 2027 |
elements to the sequence. If `sz <= size()`, equivalent to
|
| 2028 |
|
| 2029 |
``` cpp
|
| 2030 |
list<T>::iterator it = begin();
|
| 2031 |
advance(it, sz);
|
| 2032 |
erase(it, end());
|
| 2033 |
```
|
| 2034 |
|
| 2035 |
-
*Requires:* `T` shall be `
|
| 2036 |
|
| 2037 |
``` cpp
|
| 2038 |
void resize(size_type sz, const T& c);
|
| 2039 |
```
|
| 2040 |
|
|
@@ -2179,11 +2222,11 @@ iterator `i` for which the following conditions hold:
|
|
| 2179 |
references to the erased elements.
|
| 2180 |
|
| 2181 |
*Throws:* Nothing unless an exception is thrown by `*i == value` or
|
| 2182 |
`pred(*i) != false`.
|
| 2183 |
|
| 2184 |
-
*Remarks:* Stable.
|
| 2185 |
|
| 2186 |
*Complexity:* Exactly `size()` applications of the corresponding
|
| 2187 |
predicate.
|
| 2188 |
|
| 2189 |
``` cpp
|
|
@@ -2196,11 +2239,11 @@ of equal elements referred to by the iterator `i` in the range
|
|
| 2196 |
\[`first + 1`, `last`) for which `*i == *(i-1)` (for the version of
|
| 2197 |
`unique` with no arguments) or `pred(*i, *(i - 1))` (for the version of
|
| 2198 |
`unique` with a predicate argument) holds. Invalidates only the
|
| 2199 |
iterators and references to the erased elements.
|
| 2200 |
|
| 2201 |
-
*Throws:* Nothing unless an exception
|
| 2202 |
`pred(*i, *(i - 1))`
|
| 2203 |
|
| 2204 |
*Complexity:* If the range `[first, last)` is not empty, exactly
|
| 2205 |
`(last - first) - 1` applications of the corresponding predicate,
|
| 2206 |
otherwise no applications of the predicate.
|
|
@@ -2225,13 +2268,14 @@ according to the ordering defined by `comp`; that is, for every iterator
|
|
| 2225 |
elements of `x` now refer to those same elements but as members of
|
| 2226 |
`*this`. Iterators referring to the moved elements will continue to
|
| 2227 |
refer to their elements, but they now behave as iterators into `*this`,
|
| 2228 |
not into `x`.
|
| 2229 |
|
| 2230 |
-
*Remarks:* Stable. If `(&x != this)` the range
|
| 2231 |
-
empty after the merge. No elements are copied
|
| 2232 |
-
behavior is undefined if
|
|
|
|
| 2233 |
|
| 2234 |
*Complexity:* At most `size() + x.size() - 1` applications of `comp` if
|
| 2235 |
`(&x != this)`; otherwise, no applications of `comp` are performed. If
|
| 2236 |
an exception is thrown other than by a comparison there are no effects.
|
| 2237 |
|
|
@@ -2254,11 +2298,11 @@ second version) shall define a strict weak ordering ([[alg.sorting]]).
|
|
| 2254 |
|
| 2255 |
*Effects:* Sorts the list according to the `operator<` or a `Compare`
|
| 2256 |
function object. Does not affect the validity of iterators and
|
| 2257 |
references.
|
| 2258 |
|
| 2259 |
-
*Remarks:* Stable.
|
| 2260 |
|
| 2261 |
*Complexity:* Approximately N log(N) comparisons, where `N == size()`.
|
| 2262 |
|
| 2263 |
#### `list` specialized algorithms <a id="list.special">[[list.special]]</a>
|
| 2264 |
|
|
@@ -2315,12 +2359,13 @@ namespace std {
|
|
| 2315 |
typedef typename allocator_traits<Allocator>::const_pointer const_pointer;
|
| 2316 |
typedef std::reverse_iterator<iterator> reverse_iterator;
|
| 2317 |
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
| 2318 |
|
| 2319 |
// [vector.cons], construct/copy/destroy:
|
| 2320 |
-
|
| 2321 |
-
explicit vector(
|
|
|
|
| 2322 |
vector(size_type n, const T& value, const Allocator& = Allocator());
|
| 2323 |
template <class InputIterator>
|
| 2324 |
vector(InputIterator first, InputIterator last,
|
| 2325 |
const Allocator& = Allocator());
|
| 2326 |
vector(const vector& x);
|
|
@@ -2417,24 +2462,25 @@ namespace std {
|
|
| 2417 |
```
|
| 2418 |
|
| 2419 |
#### `vector` constructors, copy, and assignment <a id="vector.cons">[[vector.cons]]</a>
|
| 2420 |
|
| 2421 |
``` cpp
|
| 2422 |
-
explicit vector(const Allocator&
|
| 2423 |
```
|
| 2424 |
|
| 2425 |
*Effects:* Constructs an empty `vector`, using the specified allocator.
|
| 2426 |
|
| 2427 |
*Complexity:* Constant.
|
| 2428 |
|
| 2429 |
``` cpp
|
| 2430 |
-
explicit vector(size_type n);
|
| 2431 |
```
|
| 2432 |
|
| 2433 |
-
*Effects:* Constructs a `vector` with `n`
|
|
|
|
| 2434 |
|
| 2435 |
-
*Requires:* `T` shall be `
|
| 2436 |
|
| 2437 |
*Complexity:* Linear in `n`.
|
| 2438 |
|
| 2439 |
``` cpp
|
| 2440 |
vector(size_type n, const T& value,
|
|
@@ -2461,33 +2507,10 @@ using the specified allocator.
|
|
| 2461 |
is the distance between `first` and `last`) and no reallocations if
|
| 2462 |
iterators first and last are of forward, bidirectional, or random access
|
| 2463 |
categories. It makes order `N` calls to the copy constructor of `T` and
|
| 2464 |
order log(N) reallocations if they are just input iterators.
|
| 2465 |
|
| 2466 |
-
``` cpp
|
| 2467 |
-
template <class InputIterator>
|
| 2468 |
-
void assign(InputIterator first, InputIterator last);
|
| 2469 |
-
```
|
| 2470 |
-
|
| 2471 |
-
*Effects:*
|
| 2472 |
-
|
| 2473 |
-
``` cpp
|
| 2474 |
-
erase(begin(), end());
|
| 2475 |
-
insert(begin(), first, last);
|
| 2476 |
-
```
|
| 2477 |
-
|
| 2478 |
-
``` cpp
|
| 2479 |
-
void assign(size_type n, const T& t);
|
| 2480 |
-
```
|
| 2481 |
-
|
| 2482 |
-
*Effects:*
|
| 2483 |
-
|
| 2484 |
-
``` cpp
|
| 2485 |
-
erase(begin(), end());
|
| 2486 |
-
insert(begin(), n, t);
|
| 2487 |
-
```
|
| 2488 |
-
|
| 2489 |
#### `vector` capacity <a id="vector.capacity">[[vector.capacity]]</a>
|
| 2490 |
|
| 2491 |
``` cpp
|
| 2492 |
size_type capacity() const noexcept;
|
| 2493 |
```
|
|
@@ -2497,10 +2520,12 @@ requiring reallocation.
|
|
| 2497 |
|
| 2498 |
``` cpp
|
| 2499 |
void reserve(size_type n);
|
| 2500 |
```
|
| 2501 |
|
|
|
|
|
|
|
| 2502 |
*Effects:* A directive that informs a `vector` of a planned change in
|
| 2503 |
size, so that it can manage the storage allocation accordingly. After
|
| 2504 |
`reserve()`, `capacity()` is greater or equal to the argument of
|
| 2505 |
`reserve` if reallocation happens; and equal to the previous value of
|
| 2506 |
`capacity()` otherwise. Reallocation happens at this point if and only
|
|
@@ -2512,22 +2537,28 @@ non-`CopyInsertable` type, there are no effects.
|
|
| 2512 |
most linear time in the size of the sequence.
|
| 2513 |
|
| 2514 |
*Throws:* `length_error` if `n > max_size()`.[^4]
|
| 2515 |
|
| 2516 |
*Remarks:* Reallocation invalidates all the references, pointers, and
|
| 2517 |
-
iterators referring to the elements in the sequence.
|
| 2518 |
-
|
| 2519 |
-
|
| 2520 |
-
|
| 2521 |
|
| 2522 |
``` cpp
|
| 2523 |
void shrink_to_fit();
|
| 2524 |
```
|
| 2525 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2526 |
*Remarks:* `shrink_to_fit` is a non-binding request to reduce
|
| 2527 |
`capacity()` to `size()`. The request is non-binding to allow latitude
|
| 2528 |
-
for implementation-specific optimizations.
|
|
|
|
|
|
|
| 2529 |
|
| 2530 |
``` cpp
|
| 2531 |
void swap(vector& x);
|
| 2532 |
```
|
| 2533 |
|
|
@@ -2538,34 +2569,32 @@ of `x`.
|
|
| 2538 |
|
| 2539 |
``` cpp
|
| 2540 |
void resize(size_type sz);
|
| 2541 |
```
|
| 2542 |
|
| 2543 |
-
*Effects:* If `sz <= size()`, equivalent to
|
| 2544 |
-
`
|
| 2545 |
-
|
| 2546 |
|
| 2547 |
-
*Requires:* `T` shall be `
|
|
|
|
| 2548 |
|
| 2549 |
-
|
| 2550 |
-
void resize(size_type sz, const T& c);
|
| 2551 |
-
```
|
| 2552 |
-
|
| 2553 |
-
*Effects:*
|
| 2554 |
-
|
| 2555 |
-
``` cpp
|
| 2556 |
-
if (sz > size())
|
| 2557 |
-
insert(end(), sz-size(), c);
|
| 2558 |
-
else if (sz < size())
|
| 2559 |
-
erase(begin()+sz, end());
|
| 2560 |
-
else
|
| 2561 |
-
; // do nothing
|
| 2562 |
-
```
|
| 2563 |
-
|
| 2564 |
-
*Requires:* If an exception is thrown other than by the move constructor
|
| 2565 |
of a non-`CopyInsertable` `T` there are no effects.
|
| 2566 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2567 |
#### `vector` data <a id="vector.data">[[vector.data]]</a>
|
| 2568 |
|
| 2569 |
``` cpp
|
| 2570 |
T* data() noexcept;
|
| 2571 |
const T* data() const noexcept;
|
|
@@ -2595,12 +2624,15 @@ void push_back(T&& x);
|
|
| 2595 |
*Remarks:* Causes reallocation if the new size is greater than the old
|
| 2596 |
capacity. If no reallocation happens, all the iterators and references
|
| 2597 |
before the insertion point remain valid. If an exception is thrown other
|
| 2598 |
than by the copy constructor, move constructor, assignment operator, or
|
| 2599 |
move assignment operator of `T` or by any `InputIterator` operation
|
| 2600 |
-
there are no effects. If an exception is thrown
|
| 2601 |
-
|
|
|
|
|
|
|
|
|
|
| 2602 |
|
| 2603 |
*Complexity:* The complexity is linear in the number of elements
|
| 2604 |
inserted plus the distance to the end of the vector.
|
| 2605 |
|
| 2606 |
``` cpp
|
|
@@ -2666,12 +2698,14 @@ namespace std {
|
|
| 2666 |
reference& operator=(const reference& x) noexcept;
|
| 2667 |
void flip() noexcept; // flips the bit
|
| 2668 |
};
|
| 2669 |
|
| 2670 |
// construct/copy/destroy:
|
| 2671 |
-
|
| 2672 |
-
explicit vector(
|
|
|
|
|
|
|
| 2673 |
const Allocator& = Allocator());
|
| 2674 |
template <class InputIterator>
|
| 2675 |
vector(InputIterator first, InputIterator last,
|
| 2676 |
const Allocator& = Allocator());
|
| 2677 |
vector(const vector<bool,Allocator>& x);
|
|
@@ -2680,15 +2714,15 @@ namespace std {
|
|
| 2680 |
vector(vector&&, const Allocator&);
|
| 2681 |
vector(initializer_list<bool>, const Allocator& = Allocator()));
|
| 2682 |
~vector();
|
| 2683 |
vector<bool,Allocator>& operator=(const vector<bool,Allocator>& x);
|
| 2684 |
vector<bool,Allocator>& operator=(vector<bool,Allocator>&& x);
|
| 2685 |
-
vector operator=(initializer_list<bool>);
|
| 2686 |
template <class InputIterator>
|
| 2687 |
void assign(InputIterator first, InputIterator last);
|
| 2688 |
void assign(size_type n, const bool& t);
|
| 2689 |
-
void assign(initializer_list<bool>;
|
| 2690 |
allocator_type get_allocator() const noexcept;
|
| 2691 |
|
| 2692 |
// iterators:
|
| 2693 |
iterator begin() noexcept;
|
| 2694 |
const_iterator begin() const noexcept;
|
|
@@ -2722,12 +2756,14 @@ namespace std {
|
|
| 2722 |
const_reference front() const;
|
| 2723 |
reference back();
|
| 2724 |
const_reference back() const;
|
| 2725 |
|
| 2726 |
// modifiers:
|
|
|
|
| 2727 |
void push_back(const bool& x);
|
| 2728 |
void pop_back();
|
|
|
|
| 2729 |
iterator insert(const_iterator position, const bool& x);
|
| 2730 |
iterator insert (const_iterator position, size_type n, const bool& x);
|
| 2731 |
template <class InputIterator>
|
| 2732 |
iterator insert(const_iterator position,
|
| 2733 |
InputIterator first, InputIterator last);
|
|
@@ -2781,12 +2817,12 @@ y = b;
|
|
| 2781 |
|
| 2782 |
``` cpp
|
| 2783 |
template <class Allocator> struct hash<vector<bool, Allocator> >;
|
| 2784 |
```
|
| 2785 |
|
| 2786 |
-
|
| 2787 |
-
|
| 2788 |
|
| 2789 |
## Associative containers <a id="associative">[[associative]]</a>
|
| 2790 |
|
| 2791 |
### In general <a id="associative.general">[[associative.general]]</a>
|
| 2792 |
|
|
@@ -2968,28 +3004,32 @@ namespace std {
|
|
| 2968 |
return comp(x.first, y.first);
|
| 2969 |
}
|
| 2970 |
};
|
| 2971 |
|
| 2972 |
// [map.cons], construct/copy/destroy:
|
| 2973 |
-
|
|
|
|
| 2974 |
const Allocator& = Allocator());
|
| 2975 |
template <class InputIterator>
|
| 2976 |
map(InputIterator first, InputIterator last,
|
| 2977 |
const Compare& comp = Compare(), const Allocator& = Allocator());
|
| 2978 |
-
map(const map
|
| 2979 |
-
map(map
|
| 2980 |
explicit map(const Allocator&);
|
| 2981 |
map(const map&, const Allocator&);
|
| 2982 |
map(map&&, const Allocator&);
|
| 2983 |
map(initializer_list<value_type>,
|
| 2984 |
const Compare& = Compare(),
|
| 2985 |
const Allocator& = Allocator());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2986 |
~map();
|
| 2987 |
-
map
|
| 2988 |
-
|
| 2989 |
-
map<Key,T,Compare,Allocator>&
|
| 2990 |
-
operator=(map<Key,T,Compare,Allocator>&& x);
|
| 2991 |
map& operator=(initializer_list<value_type>);
|
| 2992 |
allocator_type get_allocator() const noexcept;
|
| 2993 |
|
| 2994 |
// iterators:
|
| 2995 |
iterator begin() noexcept;
|
|
@@ -3031,31 +3071,44 @@ namespace std {
|
|
| 3031 |
void insert(initializer_list<value_type>);
|
| 3032 |
|
| 3033 |
iterator erase(const_iterator position);
|
| 3034 |
size_type erase(const key_type& x);
|
| 3035 |
iterator erase(const_iterator first, const_iterator last);
|
| 3036 |
-
void swap(map
|
| 3037 |
void clear() noexcept;
|
| 3038 |
|
| 3039 |
// observers:
|
| 3040 |
key_compare key_comp() const;
|
| 3041 |
value_compare value_comp() const;
|
| 3042 |
|
| 3043 |
-
//
|
| 3044 |
iterator find(const key_type& x);
|
| 3045 |
const_iterator find(const key_type& x) const;
|
|
|
|
|
|
|
|
|
|
| 3046 |
size_type count(const key_type& x) const;
|
|
|
|
| 3047 |
|
| 3048 |
iterator lower_bound(const key_type& x);
|
| 3049 |
const_iterator lower_bound(const key_type& x) const;
|
|
|
|
|
|
|
|
|
|
| 3050 |
iterator upper_bound(const key_type& x);
|
| 3051 |
const_iterator upper_bound(const key_type& x) const;
|
|
|
|
|
|
|
| 3052 |
|
| 3053 |
pair<iterator,iterator>
|
| 3054 |
equal_range(const key_type& x);
|
| 3055 |
pair<const_iterator,const_iterator>
|
| 3056 |
equal_range(const key_type& x) const;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3057 |
};
|
| 3058 |
|
| 3059 |
template <class Key, class T, class Compare, class Allocator>
|
| 3060 |
bool operator==(const map<Key,T,Compare,Allocator>& x,
|
| 3061 |
const map<Key,T,Compare,Allocator>& y);
|
|
@@ -3083,11 +3136,11 @@ namespace std {
|
|
| 3083 |
```
|
| 3084 |
|
| 3085 |
#### `map` constructors, copy, and assignment <a id="map.cons">[[map.cons]]</a>
|
| 3086 |
|
| 3087 |
``` cpp
|
| 3088 |
-
explicit map(const Compare& comp
|
| 3089 |
const Allocator& = Allocator());
|
| 3090 |
```
|
| 3091 |
|
| 3092 |
*Effects:* Constructs an empty `map` using the specified comparison
|
| 3093 |
object and allocator.
|
|
@@ -3098,13 +3151,13 @@ object and allocator.
|
|
| 3098 |
template <class InputIterator>
|
| 3099 |
map(InputIterator first, InputIterator last,
|
| 3100 |
const Compare& comp = Compare(), const Allocator& = Allocator());
|
| 3101 |
```
|
| 3102 |
|
| 3103 |
-
*Requires:* If the iterator’s
|
| 3104 |
a const rvalue `pair<key_type, mapped_type>`, then both `key_type` and
|
| 3105 |
-
`mapped_type` shall be `
|
| 3106 |
|
| 3107 |
*Effects:* Constructs an empty `map` using the specified comparison
|
| 3108 |
object and allocator, and inserts elements from the range \[`first`,
|
| 3109 |
`last`).
|
| 3110 |
|
|
@@ -3118,31 +3171,31 @@ T& operator[](const key_type& x);
|
|
| 3118 |
```
|
| 3119 |
|
| 3120 |
*Effects:* If there is no key equivalent to `x` in the map, inserts
|
| 3121 |
`value_type(x, T())` into the map.
|
| 3122 |
|
| 3123 |
-
*Requires:* `key_type` shall be `
|
| 3124 |
-
|
| 3125 |
|
| 3126 |
*Returns:* A reference to the `mapped_type` corresponding to `x` in
|
| 3127 |
`*this`.
|
| 3128 |
|
| 3129 |
-
*Complexity:*
|
| 3130 |
|
| 3131 |
``` cpp
|
| 3132 |
T& operator[](key_type&& x);
|
| 3133 |
```
|
| 3134 |
|
| 3135 |
*Effects:* If there is no key equivalent to `x` in the map, inserts
|
| 3136 |
`value_type(std::move(x), T())` into the map.
|
| 3137 |
|
| 3138 |
-
*Requires:* `mapped_type` shall be `
|
| 3139 |
|
| 3140 |
*Returns:* A reference to the `mapped_type` corresponding to `x` in
|
| 3141 |
`*this`.
|
| 3142 |
|
| 3143 |
-
*Complexity:*
|
| 3144 |
|
| 3145 |
``` cpp
|
| 3146 |
T& at(const key_type& x);
|
| 3147 |
const T& at(const key_type& x) const;
|
| 3148 |
```
|
|
@@ -3151,58 +3204,27 @@ const T& at(const key_type& x) const;
|
|
| 3151 |
`*this`.
|
| 3152 |
|
| 3153 |
*Throws:* An exception object of type `out_of_range` if no such element
|
| 3154 |
is present.
|
| 3155 |
|
| 3156 |
-
*Complexity:*
|
| 3157 |
|
| 3158 |
#### `map` modifiers <a id="map.modifiers">[[map.modifiers]]</a>
|
| 3159 |
|
| 3160 |
``` cpp
|
| 3161 |
template <class P> pair<iterator, bool> insert(P&& x);
|
| 3162 |
-
template <class P>
|
| 3163 |
template <class InputIterator>
|
| 3164 |
void insert(InputIterator first, InputIterator last);
|
| 3165 |
```
|
| 3166 |
|
| 3167 |
-
*
|
|
|
|
|
|
|
| 3168 |
|
| 3169 |
-
|
| 3170 |
-
|
| 3171 |
-
converted to `value_type` and inserted into the `map`. Specifically, in
|
| 3172 |
-
such cases `CopyConstructible` is not required of `key_type` or
|
| 3173 |
-
`mapped_type` unless the conversion from `P` specifically requires it
|
| 3174 |
-
(e.g., if `P` is a `tuple<const key_type, mapped_type>`, then `key_type`
|
| 3175 |
-
must be `CopyConstructible`). The signature taking `InputIterator`
|
| 3176 |
-
parameters does not require `CopyConstructible` of either `key_type` or
|
| 3177 |
-
`mapped_type` if the dereferenced `InputIterator` returns a non-const
|
| 3178 |
-
rvalue `pair<key_type,mapped_type>`. Otherwise `CopyConstructible` is
|
| 3179 |
-
required for both `key_type` and `mapped_type`.
|
| 3180 |
-
|
| 3181 |
-
#### `map` operations <a id="map.ops">[[map.ops]]</a>
|
| 3182 |
-
|
| 3183 |
-
``` cpp
|
| 3184 |
-
iterator find(const key_type& x);
|
| 3185 |
-
const_iterator find(const key_type& x) const;
|
| 3186 |
-
|
| 3187 |
-
iterator lower_bound(const key_type& x);
|
| 3188 |
-
const_iterator lower_bound(const key_type& x) const;
|
| 3189 |
-
|
| 3190 |
-
iterator upper_bound(const key_type& x);
|
| 3191 |
-
const_iterator upper_bound(const key_type &x) const;
|
| 3192 |
-
|
| 3193 |
-
pair<iterator, iterator>
|
| 3194 |
-
equal_range(const key_type &x);
|
| 3195 |
-
pair<const_iterator, const_iterator>
|
| 3196 |
-
equal_range(const key_type& x) const;
|
| 3197 |
-
```
|
| 3198 |
-
|
| 3199 |
-
The `find`, `lower_bound`, `upper_bound` and `equal_range` member
|
| 3200 |
-
functions each have two versions, one const and the other non-const. In
|
| 3201 |
-
each case the behavior of the two functions is identical except that the
|
| 3202 |
-
const version returns a `const_iterator` and the non-const version an
|
| 3203 |
-
`iterator` ([[associative.reqmts]]).
|
| 3204 |
|
| 3205 |
#### `map` specialized algorithms <a id="map.special">[[map.special]]</a>
|
| 3206 |
|
| 3207 |
``` cpp
|
| 3208 |
template <class Key, class T, class Compare, class Allocator>
|
|
@@ -3273,29 +3295,33 @@ namespace std {
|
|
| 3273 |
return comp(x.first, y.first);
|
| 3274 |
}
|
| 3275 |
};
|
| 3276 |
|
| 3277 |
// construct/copy/destroy:
|
| 3278 |
-
|
|
|
|
| 3279 |
const Allocator& = Allocator());
|
| 3280 |
template <class InputIterator>
|
| 3281 |
multimap(InputIterator first, InputIterator last,
|
| 3282 |
const Compare& comp = Compare(),
|
| 3283 |
const Allocator& = Allocator());
|
| 3284 |
-
multimap(const multimap
|
| 3285 |
-
multimap(multimap
|
| 3286 |
explicit multimap(const Allocator&);
|
| 3287 |
multimap(const multimap&, const Allocator&);
|
| 3288 |
multimap(multimap&&, const Allocator&);
|
| 3289 |
multimap(initializer_list<value_type>,
|
| 3290 |
const Compare& = Compare(),
|
| 3291 |
const Allocator& = Allocator());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3292 |
~multimap();
|
| 3293 |
-
multimap
|
| 3294 |
-
|
| 3295 |
-
multimap<Key,T,Compare,Allocator>&
|
| 3296 |
-
operator=(multimap<Key,T,Compare,Allocator>&& x);
|
| 3297 |
multimap& operator=(initializer_list<value_type>);
|
| 3298 |
allocator_type get_allocator() const noexcept;
|
| 3299 |
|
| 3300 |
// iterators:
|
| 3301 |
iterator begin() noexcept;
|
|
@@ -3330,31 +3356,44 @@ namespace std {
|
|
| 3330 |
void insert(initializer_list<value_type>);
|
| 3331 |
|
| 3332 |
iterator erase(const_iterator position);
|
| 3333 |
size_type erase(const key_type& x);
|
| 3334 |
iterator erase(const_iterator first, const_iterator last);
|
| 3335 |
-
void swap(multimap
|
| 3336 |
void clear() noexcept;
|
| 3337 |
|
| 3338 |
// observers:
|
| 3339 |
key_compare key_comp() const;
|
| 3340 |
value_compare value_comp() const;
|
| 3341 |
|
| 3342 |
// map operations:
|
| 3343 |
iterator find(const key_type& x);
|
| 3344 |
const_iterator find(const key_type& x) const;
|
|
|
|
|
|
|
|
|
|
| 3345 |
size_type count(const key_type& x) const;
|
|
|
|
| 3346 |
|
| 3347 |
iterator lower_bound(const key_type& x);
|
| 3348 |
const_iterator lower_bound(const key_type& x) const;
|
|
|
|
|
|
|
|
|
|
| 3349 |
iterator upper_bound(const key_type& x);
|
| 3350 |
const_iterator upper_bound(const key_type& x) const;
|
|
|
|
|
|
|
| 3351 |
|
| 3352 |
pair<iterator,iterator>
|
| 3353 |
equal_range(const key_type& x);
|
| 3354 |
pair<const_iterator,const_iterator>
|
| 3355 |
equal_range(const key_type& x) const;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3356 |
};
|
| 3357 |
|
| 3358 |
template <class Key, class T, class Compare, class Allocator>
|
| 3359 |
bool operator==(const multimap<Key,T,Compare,Allocator>& x,
|
| 3360 |
const multimap<Key,T,Compare,Allocator>& y);
|
|
@@ -3382,11 +3421,11 @@ namespace std {
|
|
| 3382 |
```
|
| 3383 |
|
| 3384 |
#### `multimap` constructors <a id="multimap.cons">[[multimap.cons]]</a>
|
| 3385 |
|
| 3386 |
``` cpp
|
| 3387 |
-
explicit multimap(const Compare& comp
|
| 3388 |
const Allocator& = Allocator());
|
| 3389 |
```
|
| 3390 |
|
| 3391 |
*Effects:* Constructs an empty `multimap` using the specified comparison
|
| 3392 |
object and allocator.
|
|
@@ -3398,13 +3437,13 @@ template <class InputIterator>
|
|
| 3398 |
multimap(InputIterator first, InputIterator last,
|
| 3399 |
const Compare& comp = Compare(),
|
| 3400 |
const Allocator& = Allocator());
|
| 3401 |
```
|
| 3402 |
|
| 3403 |
-
*Requires:* If the iterator’s
|
| 3404 |
a const rvalue `pair<key_type, mapped_type>`, then both `key_type` and
|
| 3405 |
-
`mapped_type` shall be `
|
| 3406 |
|
| 3407 |
*Effects:* Constructs an empty `multimap` using the specified comparison
|
| 3408 |
object and allocator, and inserts elements from the range \[`first`,
|
| 3409 |
`last`).
|
| 3410 |
|
|
@@ -3416,44 +3455,16 @@ sorted using `comp` and otherwise N log N, where N is `last - first`.
|
|
| 3416 |
``` cpp
|
| 3417 |
template <class P> iterator insert(P&& x);
|
| 3418 |
template <class P> iterator insert(const_iterator position, P&& x);
|
| 3419 |
```
|
| 3420 |
|
| 3421 |
-
*
|
|
|
|
|
|
|
| 3422 |
|
| 3423 |
-
|
| 3424 |
-
|
| 3425 |
-
converted to `value_type` and inserted into the `map`. Specifically, in
|
| 3426 |
-
such cases `CopyConstructible` is not required of `key_type` or
|
| 3427 |
-
`mapped_type` unless the conversion from `P` specifically requires it
|
| 3428 |
-
(e.g., if `P` is a `tuple<const key_type, mapped_type>`, then `key_type`
|
| 3429 |
-
must be `CopyConstructible`). The signature taking `InputIterator`
|
| 3430 |
-
parameters does not require `CopyConstructible` of either `key_type` or
|
| 3431 |
-
`mapped_type` if the dereferenced `InputIterator` returns a non-const
|
| 3432 |
-
rvalue `pair<key_type, mapped_type>`. Otherwise `CopyConstructible` is
|
| 3433 |
-
required for both `key_type` and `mapped_type`.
|
| 3434 |
-
|
| 3435 |
-
#### `multimap` operations <a id="multimap.ops">[[multimap.ops]]</a>
|
| 3436 |
-
|
| 3437 |
-
``` cpp
|
| 3438 |
-
iterator find(const key_type &x);
|
| 3439 |
-
const_iterator find(const key_type& x) const;
|
| 3440 |
-
|
| 3441 |
-
iterator lower_bound(const key_type& x);
|
| 3442 |
-
const_iterator lower_bound(const key_type& x) const;
|
| 3443 |
-
|
| 3444 |
-
pair<iterator, iterator>
|
| 3445 |
-
equal_range(const key_type& x);
|
| 3446 |
-
pair<const_iterator, const_iterator>
|
| 3447 |
-
equal_range(const key_type& x) const;
|
| 3448 |
-
```
|
| 3449 |
-
|
| 3450 |
-
The `find`, `lower_bound`, `upper_bound`, and `equal_range` member
|
| 3451 |
-
functions each have two versions, one const and one non-const. In each
|
| 3452 |
-
case the behavior of the two versions is identical except that the const
|
| 3453 |
-
version returns a `const_iterator` and the non-const version an
|
| 3454 |
-
`iterator` ([[associative.reqmts]]).
|
| 3455 |
|
| 3456 |
#### `multimap` specialized algorithms <a id="multimap.special">[[multimap.special]]</a>
|
| 3457 |
|
| 3458 |
``` cpp
|
| 3459 |
template <class Key, class T, class Compare, class Allocator>
|
|
@@ -3509,28 +3520,32 @@ namespace std {
|
|
| 3509 |
typedef typename allocator_traits<Allocator>::const_pointer const_pointer;
|
| 3510 |
typedef std::reverse_iterator<iterator> reverse_iterator;
|
| 3511 |
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
| 3512 |
|
| 3513 |
// [set.cons], construct/copy/destroy:
|
| 3514 |
-
|
|
|
|
| 3515 |
const Allocator& = Allocator());
|
| 3516 |
template <class InputIterator>
|
| 3517 |
set(InputIterator first, InputIterator last,
|
| 3518 |
const Compare& comp = Compare(), const Allocator& = Allocator());
|
| 3519 |
-
set(const set
|
| 3520 |
-
set(set
|
| 3521 |
explicit set(const Allocator&);
|
| 3522 |
set(const set&, const Allocator&);
|
| 3523 |
set(set&&, const Allocator&);
|
| 3524 |
set(initializer_list<value_type>,
|
| 3525 |
const Compare& = Compare(),
|
| 3526 |
const Allocator& = Allocator());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3527 |
~set();
|
| 3528 |
-
set
|
| 3529 |
-
|
| 3530 |
-
set<Key,Compare,Allocator>& operator=
|
| 3531 |
-
(set<Key,Compare,Allocator>&& x);
|
| 3532 |
set& operator=(initializer_list<value_type>);
|
| 3533 |
allocator_type get_allocator() const noexcept;
|
| 3534 |
|
| 3535 |
// iterators:
|
| 3536 |
iterator begin() noexcept;
|
|
@@ -3565,31 +3580,42 @@ namespace std {
|
|
| 3565 |
void insert(initializer_list<value_type>);
|
| 3566 |
|
| 3567 |
iterator erase(const_iterator position);
|
| 3568 |
size_type erase(const key_type& x);
|
| 3569 |
iterator erase(const_iterator first, const_iterator last);
|
| 3570 |
-
void swap(set
|
| 3571 |
void clear() noexcept;
|
| 3572 |
|
| 3573 |
// observers:
|
| 3574 |
key_compare key_comp() const;
|
| 3575 |
value_compare value_comp() const;
|
| 3576 |
|
| 3577 |
// set operations:
|
| 3578 |
iterator find(const key_type& x);
|
| 3579 |
const_iterator find(const key_type& x) const;
|
|
|
|
|
|
|
| 3580 |
|
| 3581 |
size_type count(const key_type& x) const;
|
|
|
|
| 3582 |
|
| 3583 |
iterator lower_bound(const key_type& x);
|
| 3584 |
const_iterator lower_bound(const key_type& x) const;
|
|
|
|
|
|
|
| 3585 |
|
| 3586 |
iterator upper_bound(const key_type& x);
|
| 3587 |
const_iterator upper_bound(const key_type& x) const;
|
|
|
|
|
|
|
| 3588 |
|
| 3589 |
pair<iterator,iterator> equal_range(const key_type& x);
|
| 3590 |
pair<const_iterator,const_iterator> equal_range(const key_type& x) const;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3591 |
};
|
| 3592 |
|
| 3593 |
template <class Key, class Compare, class Allocator>
|
| 3594 |
bool operator==(const set<Key,Compare,Allocator>& x,
|
| 3595 |
const set<Key,Compare,Allocator>& y);
|
|
@@ -3617,11 +3643,11 @@ namespace std {
|
|
| 3617 |
```
|
| 3618 |
|
| 3619 |
#### `set` constructors, copy, and assignment <a id="set.cons">[[set.cons]]</a>
|
| 3620 |
|
| 3621 |
``` cpp
|
| 3622 |
-
explicit set(const Compare& comp
|
| 3623 |
const Allocator& = Allocator());
|
| 3624 |
```
|
| 3625 |
|
| 3626 |
*Effects:* Constructs an empty set using the specified comparison
|
| 3627 |
objects and allocator.
|
|
@@ -3636,12 +3662,12 @@ template <class InputIterator>
|
|
| 3636 |
|
| 3637 |
*Effects:* Constructs an empty `set` using the specified comparison
|
| 3638 |
object and allocator, and inserts elements from the range \[`first`,
|
| 3639 |
`last`).
|
| 3640 |
|
| 3641 |
-
*Requires:* If the iterator’s
|
| 3642 |
-
a non-const rvalue, then `Key` shall be `
|
| 3643 |
|
| 3644 |
*Complexity:* Linear in N if the range \[`first`, `last`) is already
|
| 3645 |
sorted using `comp` and otherwise N log N, where N is `last - first`.
|
| 3646 |
|
| 3647 |
#### `set` specialized algorithms <a id="set.special">[[set.special]]</a>
|
|
@@ -3701,29 +3727,33 @@ namespace std {
|
|
| 3701 |
typedef typename allocator_traits<Allocator>::const_pointer const_pointer;
|
| 3702 |
typedef std::reverse_iterator<iterator> reverse_iterator;
|
| 3703 |
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
| 3704 |
|
| 3705 |
// construct/copy/destroy:
|
| 3706 |
-
|
|
|
|
| 3707 |
const Allocator& = Allocator());
|
| 3708 |
template <class InputIterator>
|
| 3709 |
multiset(InputIterator first, InputIterator last,
|
| 3710 |
const Compare& comp = Compare(),
|
| 3711 |
const Allocator& = Allocator());
|
| 3712 |
-
multiset(const multiset
|
| 3713 |
-
multiset(multiset
|
| 3714 |
explicit multiset(const Allocator&);
|
| 3715 |
multiset(const multiset&, const Allocator&);
|
| 3716 |
multiset(multiset&&, const Allocator&);
|
| 3717 |
multiset(initializer_list<value_type>,
|
| 3718 |
const Compare& = Compare(),
|
| 3719 |
const Allocator& = Allocator());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3720 |
~multiset();
|
| 3721 |
-
multiset
|
| 3722 |
-
|
| 3723 |
-
multiset<Key,Compare,Allocator>&
|
| 3724 |
-
operator=(multiset<Key,Compare,Allocator>&& x);
|
| 3725 |
multiset& operator=(initializer_list<value_type>);
|
| 3726 |
allocator_type get_allocator() const noexcept;
|
| 3727 |
|
| 3728 |
// iterators:
|
| 3729 |
iterator begin() noexcept;
|
|
@@ -3758,31 +3788,42 @@ namespace std {
|
|
| 3758 |
void insert(initializer_list<value_type>);
|
| 3759 |
|
| 3760 |
iterator erase(const_iterator position);
|
| 3761 |
size_type erase(const key_type& x);
|
| 3762 |
iterator erase(const_iterator first, const_iterator last);
|
| 3763 |
-
void swap(multiset
|
| 3764 |
void clear() noexcept;
|
| 3765 |
|
| 3766 |
// observers:
|
| 3767 |
key_compare key_comp() const;
|
| 3768 |
value_compare value_comp() const;
|
| 3769 |
|
| 3770 |
// set operations:
|
| 3771 |
iterator find(const key_type& x);
|
| 3772 |
const_iterator find(const key_type& x) const;
|
|
|
|
|
|
|
| 3773 |
|
| 3774 |
size_type count(const key_type& x) const;
|
|
|
|
| 3775 |
|
| 3776 |
iterator lower_bound(const key_type& x);
|
| 3777 |
const_iterator lower_bound(const key_type& x) const;
|
|
|
|
|
|
|
| 3778 |
|
| 3779 |
iterator upper_bound(const key_type& x);
|
| 3780 |
const_iterator upper_bound(const key_type& x) const;
|
|
|
|
|
|
|
| 3781 |
|
| 3782 |
pair<iterator,iterator> equal_range(const key_type& x);
|
| 3783 |
pair<const_iterator,const_iterator> equal_range(const key_type& x) const;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3784 |
};
|
| 3785 |
|
| 3786 |
template <class Key, class Compare, class Allocator>
|
| 3787 |
bool operator==(const multiset<Key,Compare,Allocator>& x,
|
| 3788 |
const multiset<Key,Compare,Allocator>& y);
|
|
@@ -3810,27 +3851,27 @@ namespace std {
|
|
| 3810 |
```
|
| 3811 |
|
| 3812 |
#### `multiset` constructors <a id="multiset.cons">[[multiset.cons]]</a>
|
| 3813 |
|
| 3814 |
``` cpp
|
| 3815 |
-
explicit multiset(const Compare& comp
|
| 3816 |
const Allocator& = Allocator());
|
| 3817 |
```
|
| 3818 |
|
| 3819 |
*Effects:* Constructs an empty set using the specified comparison object
|
| 3820 |
and allocator.
|
| 3821 |
|
| 3822 |
*Complexity:* Constant.
|
| 3823 |
|
| 3824 |
``` cpp
|
| 3825 |
template <class InputIterator>
|
| 3826 |
-
multiset(InputIterator first, last,
|
| 3827 |
const Compare& comp = Compare(), const Allocator& = Allocator());
|
| 3828 |
```
|
| 3829 |
|
| 3830 |
-
*Requires:* If the iterator’s
|
| 3831 |
-
a const rvalue, then `Key` shall be `
|
| 3832 |
|
| 3833 |
*Effects:* Constructs an empty `multiset` using the specified comparison
|
| 3834 |
object and allocator, and inserts elements from the range \[`first`,
|
| 3835 |
`last`).
|
| 3836 |
|
|
@@ -3986,24 +4027,25 @@ namespace std {
|
|
| 3986 |
typedef std::pair<const Key, T> value_type;
|
| 3987 |
typedef T mapped_type;
|
| 3988 |
typedef Hash hasher;
|
| 3989 |
typedef Pred key_equal;
|
| 3990 |
typedef Allocator allocator_type;
|
| 3991 |
-
typedef typename
|
| 3992 |
-
typedef typename
|
| 3993 |
-
typedef
|
| 3994 |
-
typedef
|
| 3995 |
typedef implementation-defined size_type;
|
| 3996 |
typedef implementation-defined difference_type;
|
| 3997 |
|
| 3998 |
typedef implementation-defined iterator;
|
| 3999 |
typedef implementation-defined const_iterator;
|
| 4000 |
typedef implementation-defined local_iterator;
|
| 4001 |
typedef implementation-defined const_local_iterator;
|
| 4002 |
|
| 4003 |
// construct/destroy/copy
|
| 4004 |
-
|
|
|
|
| 4005 |
const hasher& hf = hasher(),
|
| 4006 |
const key_equal& eql = key_equal(),
|
| 4007 |
const allocator_type& a = allocator_type());
|
| 4008 |
template <class InputIterator>
|
| 4009 |
unordered_map(InputIterator f, InputIterator l,
|
|
@@ -4019,10 +4061,26 @@ namespace std {
|
|
| 4019 |
unordered_map(initializer_list<value_type>,
|
| 4020 |
size_type = see below,
|
| 4021 |
const hasher& hf = hasher(),
|
| 4022 |
const key_equal& eql = key_equal(),
|
| 4023 |
const allocator_type& a = allocator_type());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4024 |
~unordered_map();
|
| 4025 |
unordered_map& operator=(const unordered_map&);
|
| 4026 |
unordered_map& operator=(unordered_map&&);
|
| 4027 |
unordered_map& operator=(initializer_list<value_type>);
|
| 4028 |
allocator_type get_allocator() const noexcept;
|
|
@@ -4107,19 +4165,20 @@ namespace std {
|
|
| 4107 |
```
|
| 4108 |
|
| 4109 |
#### `unordered_map` constructors <a id="unord.map.cnstr">[[unord.map.cnstr]]</a>
|
| 4110 |
|
| 4111 |
``` cpp
|
| 4112 |
-
|
|
|
|
| 4113 |
const hasher& hf = hasher(),
|
| 4114 |
const key_equal& eql = key_equal(),
|
| 4115 |
const allocator_type& a = allocator_type());
|
| 4116 |
```
|
| 4117 |
|
| 4118 |
*Effects:* Constructs an empty `unordered_map` using the specified hash
|
| 4119 |
function, key equality function, and allocator, and using at least *`n`*
|
| 4120 |
-
buckets.
|
| 4121 |
*implementation-defined*. `max_load_factor()` returns 1.0.
|
| 4122 |
|
| 4123 |
*Complexity:* Constant.
|
| 4124 |
|
| 4125 |
``` cpp
|
|
@@ -4144,13 +4203,13 @@ buckets. If *`n`* is not provided, the number of buckets is
|
|
| 4144 |
``` cpp
|
| 4145 |
mapped_type& operator[](const key_type& k);
|
| 4146 |
mapped_type& operator[](key_type&& k);
|
| 4147 |
```
|
| 4148 |
|
| 4149 |
-
*Requires:* `mapped_type` shall be `
|
| 4150 |
-
operator, `key_type` shall be `
|
| 4151 |
-
operator, `key_type` shall be `MoveConstructible`.
|
| 4152 |
|
| 4153 |
*Effects:* If the `unordered_map` does not already contain an element
|
| 4154 |
whose key is equivalent to *`k`*, the first operator inserts the value
|
| 4155 |
`value_type(k, mapped_type())` and the second operator inserts the value
|
| 4156 |
`value_type(std::move(k), mapped_type())`.
|
|
@@ -4176,44 +4235,25 @@ is present.
|
|
| 4176 |
``` cpp
|
| 4177 |
template <class P>
|
| 4178 |
pair<iterator, bool> insert(P&& obj);
|
| 4179 |
```
|
| 4180 |
|
| 4181 |
-
*
|
| 4182 |
-
|
| 4183 |
-
*Effects:* Inserts `obj` converted to `value_type` if and only if there
|
| 4184 |
-
is no element in the container with key equivalent to the key of
|
| 4185 |
-
`value_type(obj)`.
|
| 4186 |
-
|
| 4187 |
-
*Returns:* The `bool` component of the returned `pair` object indicates
|
| 4188 |
-
whether the insertion took place and the iterator component points to
|
| 4189 |
-
the element with key equivalent to the key of `value_type(obj)`.
|
| 4190 |
-
|
| 4191 |
-
*Complexity:* Average case 𝑂(1), worst case 𝑂(`size()`).
|
| 4192 |
|
| 4193 |
*Remarks:* This signature shall not participate in overload resolution
|
| 4194 |
-
unless `P` is
|
| 4195 |
|
| 4196 |
``` cpp
|
| 4197 |
template <class P>
|
| 4198 |
iterator insert(const_iterator hint, P&& obj);
|
| 4199 |
```
|
| 4200 |
|
| 4201 |
-
*
|
| 4202 |
-
|
| 4203 |
-
*Effects:* Inserts `obj` converted to `value_type` if and only if there
|
| 4204 |
-
is no element in the container with key equivalent to the key of
|
| 4205 |
-
`value_type(obj)`. The iterator `hint` is a hint pointing to where the
|
| 4206 |
-
search should start.
|
| 4207 |
-
|
| 4208 |
-
*Returns:* An iterator that points to the element with key equivalent to
|
| 4209 |
-
the key of `value_type(obj)`.
|
| 4210 |
-
|
| 4211 |
-
*Complexity:* Average case 𝑂(1), worst case 𝑂(`size()`).
|
| 4212 |
|
| 4213 |
*Remarks:* This signature shall not participate in overload resolution
|
| 4214 |
-
unless `P` is
|
| 4215 |
|
| 4216 |
#### `unordered_map` swap <a id="unord.map.swap">[[unord.map.swap]]</a>
|
| 4217 |
|
| 4218 |
``` cpp
|
| 4219 |
template <class Key, class T, class Hash, class Pred, class Alloc>
|
|
@@ -4261,24 +4301,25 @@ namespace std {
|
|
| 4261 |
typedef std::pair<const Key, T> value_type;
|
| 4262 |
typedef T mapped_type;
|
| 4263 |
typedef Hash hasher;
|
| 4264 |
typedef Pred key_equal;
|
| 4265 |
typedef Allocator allocator_type;
|
| 4266 |
-
typedef typename
|
| 4267 |
-
typedef typename
|
| 4268 |
-
typedef
|
| 4269 |
-
typedef
|
| 4270 |
typedef implementation-defined size_type;
|
| 4271 |
typedef implementation-defined difference_type;
|
| 4272 |
|
| 4273 |
typedef implementation-defined iterator;
|
| 4274 |
typedef implementation-defined const_iterator;
|
| 4275 |
typedef implementation-defined local_iterator;
|
| 4276 |
typedef implementation-defined const_local_iterator;
|
| 4277 |
|
| 4278 |
// construct/destroy/copy
|
| 4279 |
-
|
|
|
|
| 4280 |
const hasher& hf = hasher(),
|
| 4281 |
const key_equal& eql = key_equal(),
|
| 4282 |
const allocator_type& a = allocator_type());
|
| 4283 |
template <class InputIterator>
|
| 4284 |
unordered_multimap(InputIterator f, InputIterator l,
|
|
@@ -4294,10 +4335,26 @@ namespace std {
|
|
| 4294 |
unordered_multimap(initializer_list<value_type>,
|
| 4295 |
size_type = see below,
|
| 4296 |
const hasher& hf = hasher(),
|
| 4297 |
const key_equal& eql = key_equal(),
|
| 4298 |
const allocator_type& a = allocator_type());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4299 |
~unordered_multimap();
|
| 4300 |
unordered_multimap& operator=(const unordered_multimap&);
|
| 4301 |
unordered_multimap& operator=(unordered_multimap&&);
|
| 4302 |
unordered_multimap& operator=(initializer_list<value_type>);
|
| 4303 |
allocator_type get_allocator() const noexcept;
|
|
@@ -4377,19 +4434,20 @@ namespace std {
|
|
| 4377 |
```
|
| 4378 |
|
| 4379 |
#### `unordered_multimap` constructors <a id="unord.multimap.cnstr">[[unord.multimap.cnstr]]</a>
|
| 4380 |
|
| 4381 |
``` cpp
|
| 4382 |
-
|
|
|
|
| 4383 |
const hasher& hf = hasher(),
|
| 4384 |
const key_equal& eql = key_equal(),
|
| 4385 |
const allocator_type& a = allocator_type());
|
| 4386 |
```
|
| 4387 |
|
| 4388 |
*Effects:* Constructs an empty `unordered_multimap` using the specified
|
| 4389 |
hash function, key equality function, and allocator, and using at least
|
| 4390 |
-
*`n`* buckets.
|
| 4391 |
*implementation-defined*. `max_load_factor()` returns 1.0.
|
| 4392 |
|
| 4393 |
*Complexity:* Constant.
|
| 4394 |
|
| 4395 |
``` cpp
|
|
@@ -4414,39 +4472,25 @@ hash function, key equality function, and allocator, and using at least
|
|
| 4414 |
``` cpp
|
| 4415 |
template <class P>
|
| 4416 |
iterator insert(P&& obj);
|
| 4417 |
```
|
| 4418 |
|
| 4419 |
-
*
|
| 4420 |
-
|
| 4421 |
-
*Effects:* Inserts `obj` converted to `value_type`.
|
| 4422 |
-
|
| 4423 |
-
*Returns:* An iterator that points to the element with key equivalent to
|
| 4424 |
-
the key of `value_type(obj)`.
|
| 4425 |
-
|
| 4426 |
-
*Complexity:* Average case 𝑂(1), worst case 𝑂(`size()`).
|
| 4427 |
|
| 4428 |
*Remarks:* This signature shall not participate in overload resolution
|
| 4429 |
-
unless `P` is
|
| 4430 |
|
| 4431 |
``` cpp
|
| 4432 |
template <class P>
|
| 4433 |
iterator insert(const_iterator hint, P&& obj);
|
| 4434 |
```
|
| 4435 |
|
| 4436 |
-
*
|
| 4437 |
-
|
| 4438 |
-
*Effects:* Inserts `obj` converted to `value_type`. The iterator `hint`
|
| 4439 |
-
is a hint pointing to where the search should start.
|
| 4440 |
-
|
| 4441 |
-
*Returns:* An iterator that points to the element with key equivalent to
|
| 4442 |
-
the key of `value_type(obj)`.
|
| 4443 |
-
|
| 4444 |
-
*Complexity:* Average case 𝑂(1), worst case 𝑂(`size()`).
|
| 4445 |
|
| 4446 |
*Remarks:* This signature shall not participate in overload resolution
|
| 4447 |
-
unless `P` is
|
| 4448 |
|
| 4449 |
#### `unordered_multimap` swap <a id="unord.multimap.swap">[[unord.multimap.swap]]</a>
|
| 4450 |
|
| 4451 |
``` cpp
|
| 4452 |
template <class Key, class T, class Hash, class Pred, class Alloc>
|
|
@@ -4492,24 +4536,25 @@ namespace std {
|
|
| 4492 |
typedef Key key_type;
|
| 4493 |
typedef Key value_type;
|
| 4494 |
typedef Hash hasher;
|
| 4495 |
typedef Pred key_equal;
|
| 4496 |
typedef Allocator allocator_type;
|
| 4497 |
-
typedef typename
|
| 4498 |
-
typedef typename
|
| 4499 |
-
typedef
|
| 4500 |
-
typedef
|
| 4501 |
typedef implementation-defined size_type;
|
| 4502 |
typedef implementation-defined difference_type;
|
| 4503 |
|
| 4504 |
typedef implementation-defined iterator;
|
| 4505 |
typedef implementation-defined const_iterator;
|
| 4506 |
typedef implementation-defined local_iterator;
|
| 4507 |
typedef implementation-defined const_local_iterator;
|
| 4508 |
|
| 4509 |
// construct/destroy/copy
|
| 4510 |
-
|
|
|
|
| 4511 |
const hasher& hf = hasher(),
|
| 4512 |
const key_equal& eql = key_equal(),
|
| 4513 |
const allocator_type& a = allocator_type());
|
| 4514 |
template <class InputIterator>
|
| 4515 |
unordered_set(InputIterator f, InputIterator l,
|
|
@@ -4525,10 +4570,26 @@ namespace std {
|
|
| 4525 |
unordered_set(initializer_list<value_type>,
|
| 4526 |
size_type = see below,
|
| 4527 |
const hasher& hf = hasher(),
|
| 4528 |
const key_equal& eql = key_equal(),
|
| 4529 |
const allocator_type& a = allocator_type());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4530 |
~unordered_set();
|
| 4531 |
unordered_set& operator=(const unordered_set&);
|
| 4532 |
unordered_set& operator=(unordered_set&&);
|
| 4533 |
unordered_set& operator=(initializer_list<value_type>);
|
| 4534 |
allocator_type get_allocator() const noexcept;
|
|
@@ -4596,31 +4657,32 @@ namespace std {
|
|
| 4596 |
|
| 4597 |
template <class Key, class Hash, class Pred, class Alloc>
|
| 4598 |
void swap(unordered_set<Key, Hash, Pred, Alloc>& x,
|
| 4599 |
unordered_set<Key, Hash, Pred, Alloc>& y);
|
| 4600 |
|
| 4601 |
-
template <class Key, class
|
| 4602 |
-
bool operator==(const unordered_set<Key,
|
| 4603 |
-
const unordered_set<Key,
|
| 4604 |
-
template <class Key, class
|
| 4605 |
-
bool operator!=(const unordered_set<Key,
|
| 4606 |
-
const unordered_set<Key,
|
| 4607 |
}
|
| 4608 |
```
|
| 4609 |
|
| 4610 |
#### `unordered_set` constructors <a id="unord.set.cnstr">[[unord.set.cnstr]]</a>
|
| 4611 |
|
| 4612 |
``` cpp
|
| 4613 |
-
|
|
|
|
| 4614 |
const hasher& hf = hasher(),
|
| 4615 |
const key_equal& eql = key_equal(),
|
| 4616 |
const allocator_type& a = allocator_type());
|
| 4617 |
```
|
| 4618 |
|
| 4619 |
*Effects:* Constructs an empty `unordered_set` using the specified hash
|
| 4620 |
function, key equality function, and allocator, and using at least *`n`*
|
| 4621 |
-
buckets.
|
| 4622 |
*implementation-defined*. `max_load_factor()` returns 1.0.
|
| 4623 |
|
| 4624 |
*Complexity:* Constant.
|
| 4625 |
|
| 4626 |
``` cpp
|
|
@@ -4687,24 +4749,25 @@ namespace std {
|
|
| 4687 |
typedef Key key_type;
|
| 4688 |
typedef Key value_type;
|
| 4689 |
typedef Hash hasher;
|
| 4690 |
typedef Pred key_equal;
|
| 4691 |
typedef Allocator allocator_type;
|
| 4692 |
-
typedef typename
|
| 4693 |
-
typedef typename
|
| 4694 |
-
typedef
|
| 4695 |
-
typedef
|
| 4696 |
typedef implementation-defined size_type;
|
| 4697 |
typedef implementation-defined difference_type;
|
| 4698 |
|
| 4699 |
typedef implementation-defined iterator;
|
| 4700 |
typedef implementation-defined const_iterator;
|
| 4701 |
typedef implementation-defined local_iterator;
|
| 4702 |
typedef implementation-defined const_local_iterator;
|
| 4703 |
|
| 4704 |
// construct/destroy/copy
|
| 4705 |
-
|
|
|
|
| 4706 |
const hasher& hf = hasher(),
|
| 4707 |
const key_equal& eql = key_equal(),
|
| 4708 |
const allocator_type& a = allocator_type());
|
| 4709 |
template <class InputIterator>
|
| 4710 |
unordered_multiset(InputIterator f, InputIterator l,
|
|
@@ -4720,13 +4783,29 @@ namespace std {
|
|
| 4720 |
unordered_multiset(initializer_list<value_type>,
|
| 4721 |
size_type = see below,
|
| 4722 |
const hasher& hf = hasher(),
|
| 4723 |
const key_equal& eql = key_equal(),
|
| 4724 |
const allocator_type& a = allocator_type());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4725 |
~unordered_multiset();
|
| 4726 |
unordered_multiset& operator=(const unordered_multiset&);
|
| 4727 |
-
unordered_multiset operator=(unordered_multiset&&);
|
| 4728 |
unordered_multiset& operator=(initializer_list<value_type>);
|
| 4729 |
allocator_type get_allocator() const noexcept;
|
| 4730 |
|
| 4731 |
// size and capacity
|
| 4732 |
bool empty() const noexcept;
|
|
@@ -4790,31 +4869,32 @@ namespace std {
|
|
| 4790 |
};
|
| 4791 |
|
| 4792 |
template <class Key, class Hash, class Pred, class Alloc>
|
| 4793 |
void swap(unordered_multiset<Key, Hash, Pred, Alloc>& x,
|
| 4794 |
unordered_multiset<Key, Hash, Pred, Alloc>& y);
|
| 4795 |
-
template <class Key, class
|
| 4796 |
-
bool operator==(const unordered_multiset<Key,
|
| 4797 |
-
const unordered_multiset<Key,
|
| 4798 |
-
template <class Key, class
|
| 4799 |
-
bool operator!=(const unordered_multiset<Key,
|
| 4800 |
-
const unordered_multiset<Key,
|
| 4801 |
}
|
| 4802 |
```
|
| 4803 |
|
| 4804 |
#### `unordered_multiset` constructors <a id="unord.multiset.cnstr">[[unord.multiset.cnstr]]</a>
|
| 4805 |
|
| 4806 |
``` cpp
|
| 4807 |
-
|
|
|
|
| 4808 |
const hasher& hf = hasher(),
|
| 4809 |
const key_equal& eql = key_equal(),
|
| 4810 |
const allocator_type& a = allocator_type());
|
| 4811 |
```
|
| 4812 |
|
| 4813 |
*Effects:* Constructs an empty `unordered_multiset` using the specified
|
| 4814 |
hash function, key equality function, and allocator, and using at least
|
| 4815 |
-
*`n`* buckets.
|
| 4816 |
*implementation-defined*. `max_load_factor()` returns 1.0.
|
| 4817 |
|
| 4818 |
*Complexity:* Constant.
|
| 4819 |
|
| 4820 |
``` cpp
|
|
@@ -4847,12 +4927,11 @@ template <class Key, class Hash, class Pred, class Alloc>
|
|
| 4847 |
## Container adaptors <a id="container.adaptors">[[container.adaptors]]</a>
|
| 4848 |
|
| 4849 |
### In general <a id="container.adaptors.general">[[container.adaptors.general]]</a>
|
| 4850 |
|
| 4851 |
The headers `<queue>` and `<stack>` define the container adaptors
|
| 4852 |
-
`queue`, `priority_queue`, and `stack`.
|
| 4853 |
-
the requirements for sequence containers.
|
| 4854 |
|
| 4855 |
The container adaptors each take a `Container` template parameter, and
|
| 4856 |
each constructor takes a `Container` reference argument. This container
|
| 4857 |
is copied into the `Container` member of each adaptor. If the container
|
| 4858 |
takes an allocator, then a compatible allocator may be passed in to the
|
|
@@ -5368,12 +5447,12 @@ namespace std {
|
|
| 5368 |
bool operator> (const stack<T, Container>& x, const stack<T, Container>& y);
|
| 5369 |
template <class T, class Container>
|
| 5370 |
bool operator>=(const stack<T, Container>& x, const stack<T, Container>& y);
|
| 5371 |
template <class T, class Container>
|
| 5372 |
bool operator<=(const stack<T, Container>& x, const stack<T, Container>& y);
|
| 5373 |
-
template <class T, class
|
| 5374 |
-
void swap(stack<T,
|
| 5375 |
|
| 5376 |
template <class T, class Container, class Alloc>
|
| 5377 |
struct uses_allocator<stack<T, Container>, Alloc>
|
| 5378 |
: uses_allocator<Container, Alloc>::type { };
|
| 5379 |
}
|
|
@@ -5386,11 +5465,11 @@ explicit stack(const Container& cont);
|
|
| 5386 |
```
|
| 5387 |
|
| 5388 |
*Effects:* Initializes `c` with `cont`.
|
| 5389 |
|
| 5390 |
``` cpp
|
| 5391 |
-
explicit stack(Container&&
|
| 5392 |
```
|
| 5393 |
|
| 5394 |
*Effects:* Initializes `c` with `std::move(cont)`.
|
| 5395 |
|
| 5396 |
#### `stack` constructors with allocators <a id="stack.cons.alloc">[[stack.cons.alloc]]</a>
|
|
@@ -5497,10 +5576,11 @@ template <class T, class Container>
|
|
| 5497 |
|
| 5498 |
*Effects:* `x.swap(y)`.
|
| 5499 |
|
| 5500 |
<!-- Link reference definitions -->
|
| 5501 |
[alg.sorting]: algorithms.md#alg.sorting
|
|
|
|
| 5502 |
[algorithms]: algorithms.md#algorithms
|
| 5503 |
[allocator.requirements]: library.md#allocator.requirements
|
| 5504 |
[allocator.traits.members]: utilities.md#allocator.traits.members
|
| 5505 |
[array]: #array
|
| 5506 |
[array.cons]: #array.cons
|
|
@@ -5556,17 +5636,15 @@ template <class T, class Container>
|
|
| 5556 |
[list.special]: #list.special
|
| 5557 |
[map]: #map
|
| 5558 |
[map.access]: #map.access
|
| 5559 |
[map.cons]: #map.cons
|
| 5560 |
[map.modifiers]: #map.modifiers
|
| 5561 |
-
[map.ops]: #map.ops
|
| 5562 |
[map.overview]: #map.overview
|
| 5563 |
[map.special]: #map.special
|
| 5564 |
[multimap]: #multimap
|
| 5565 |
[multimap.cons]: #multimap.cons
|
| 5566 |
[multimap.modifiers]: #multimap.modifiers
|
| 5567 |
-
[multimap.ops]: #multimap.ops
|
| 5568 |
[multimap.overview]: #multimap.overview
|
| 5569 |
[multimap.special]: #multimap.special
|
| 5570 |
[multiset]: #multiset
|
| 5571 |
[multiset.cons]: #multiset.cons
|
| 5572 |
[multiset.overview]: #multiset.overview
|
|
@@ -5606,10 +5684,11 @@ template <class T, class Container>
|
|
| 5606 |
[tab:containers.lib.summary]: #tab:containers.lib.summary
|
| 5607 |
[tab:containers.optional.operations]: #tab:containers.optional.operations
|
| 5608 |
[tab:containers.reversible.requirements]: #tab:containers.reversible.requirements
|
| 5609 |
[tab:containers.sequence.optional]: #tab:containers.sequence.optional
|
| 5610 |
[tab:containers.sequence.requirements]: #tab:containers.sequence.requirements
|
|
|
|
| 5611 |
[unord]: #unord
|
| 5612 |
[unord.general]: #unord.general
|
| 5613 |
[unord.hash]: utilities.md#unord.hash
|
| 5614 |
[unord.map]: #unord.map
|
| 5615 |
[unord.map.cnstr]: #unord.map.cnstr
|
|
|
|
| 50 |
container’s element type, not for internal types used by the container.
|
| 51 |
This means, for example, that a node-based container might need to
|
| 52 |
construct nodes containing aligned buffers and call `construct` to place
|
| 53 |
the element into the buffer.
|
| 54 |
|
| 55 |
+
In Tables [[tab:containers.container.requirements]],
|
| 56 |
+
[[tab:containers.reversible.requirements]], and
|
| 57 |
+
[[tab:containers.optional.operations]] `X` denotes a container class
|
| 58 |
+
containing objects of type `T`, `a` and `b` denote values of type `X`,
|
| 59 |
+
`u` denotes an identifier, `r` denotes a non-const value of type `X`,
|
| 60 |
+
and `rv` denotes a non-const rvalue of type `X`.
|
| 61 |
|
| 62 |
Notes: the algorithm `equal()` is defined in Clause [[algorithms]].
|
| 63 |
Those entries marked “(Note A)” or “(Note B)” have linear complexity for
|
| 64 |
`array` and have constant complexity for all other standard containers.
|
| 65 |
|
|
|
|
| 71 |
|
| 72 |
returns an iterator referring to the first element in the container.
|
| 73 |
`end()` returns an iterator which is the past-the-end value for the
|
| 74 |
container. If the container is empty, then `begin() == end()`;
|
| 75 |
|
| 76 |
+
In the expressions
|
| 77 |
+
|
| 78 |
+
``` cpp
|
| 79 |
+
i == j
|
| 80 |
+
i != j
|
| 81 |
+
i < j
|
| 82 |
+
i <= j
|
| 83 |
+
i >= j
|
| 84 |
+
i > j
|
| 85 |
+
i - j
|
| 86 |
+
```
|
| 87 |
+
|
| 88 |
+
where `i` and `j` denote objects of a container’s `iterator` type,
|
| 89 |
+
either or both may be replaced by an object of the container’s
|
| 90 |
+
`const_iterator` type referring to the same element with no change in
|
| 91 |
+
semantics.
|
| 92 |
+
|
| 93 |
Unless otherwise specified, all containers defined in this clause obtain
|
| 94 |
memory using an allocator (see [[allocator.requirements]]). Copy
|
| 95 |
constructors for these container types obtain an allocator by calling
|
| 96 |
`allocator_traits<allocator_type>::select_on_container_copy_construction`
|
| 97 |
+
on the allocator belonging to the container being copied. Move
|
| 98 |
+
constructors obtain an allocator by move construction from the allocator
|
| 99 |
+
belonging to the container being moved. Such move construction of the
|
| 100 |
+
allocator shall not exit via an exception. All other constructors for
|
| 101 |
+
these container types take a `const allocator_type&` argument. If an
|
| 102 |
+
invocation of a constructor uses the default value of an optional
|
| 103 |
+
allocator argument, then the `Allocator` type must support value
|
| 104 |
+
initialization. A copy of this allocator is used for any memory
|
| 105 |
+
allocation performed, by these constructors and by all member functions,
|
| 106 |
+
during the lifetime of each container object or until the allocator is
|
| 107 |
+
replaced. The allocator may be replaced only via assignment or `swap()`.
|
| 108 |
+
Allocator replacement is performed by copy assignment, move assignment,
|
| 109 |
+
or swapping of the allocator only if
|
|
|
|
| 110 |
`allocator_traits<allocator_type>::propagate_on_container_copy_assignment::value`,
|
| 111 |
`allocator_traits<allocator_type>::propagate_on_container_move_assignment::value`,
|
| 112 |
or
|
| 113 |
`allocator_traits<allocator_type>::propagate_on_container_swap::value`
|
| 114 |
is true within the implementation of the corresponding container
|
|
|
|
| 147 |
container types defined in this Clause meet the following additional
|
| 148 |
requirements:
|
| 149 |
|
| 150 |
- if an exception is thrown by an `insert()` or `emplace()` function
|
| 151 |
while inserting a single element, that function has no effects.
|
| 152 |
+
- if an exception is thrown by a `push_back()`, `push_front()`,
|
| 153 |
+
`emplace_back()`, or `emplace_front()` function, that function has no
|
| 154 |
+
effects.
|
| 155 |
- no `erase()`, `clear()`, `pop_back()` or `pop_front()` function throws
|
| 156 |
an exception.
|
| 157 |
- no copy constructor or assignment operator of a returned iterator
|
| 158 |
throws an exception.
|
| 159 |
- no `swap()` function throws an exception.
|
|
|
|
| 181 |
except `array` meet the additional requirements of an allocator-aware
|
| 182 |
container, as described in Table [[tab:containers.allocatoraware]].
|
| 183 |
|
| 184 |
Given a container type `X` having an `allocator_type` identical to `A`
|
| 185 |
and a `value_type` identical to `T` and given an lvalue `m` of type `A`,
|
| 186 |
+
a pointer `p` of type `T*`, an expression `v` of type (possibly const)
|
| 187 |
+
`T`, and an rvalue `rv` of type `T`, the following terms are defined. If
|
| 188 |
+
`X` is not allocator-aware, the terms below are defined as if `A` were
|
| 189 |
+
`std::allocator<T>` — no allocator object needs to be created and user
|
| 190 |
+
specializations of `std::allocator<T>` are not instantiated:
|
| 191 |
|
| 192 |
+
- `T` is *`DefaultInsertable` into `X`* means that the following
|
| 193 |
+
expression is well-formed:
|
| 194 |
``` cpp
|
| 195 |
+
allocator_traits<A>::construct(m, p)
|
| 196 |
```
|
| 197 |
+
- An element of `X` is *default-inserted* if it is initialized by
|
| 198 |
+
evaluation of the expression
|
| 199 |
+
``` cpp
|
| 200 |
+
allocator_traits<A>::construct(m, p)
|
| 201 |
+
```
|
| 202 |
+
|
| 203 |
+
where `p` is the address of the uninitialized storage for the element
|
| 204 |
+
allocated within `X`.
|
| 205 |
- `T` is *`MoveInsertable` into `X`* means that the following expression
|
| 206 |
is well-formed:
|
| 207 |
``` cpp
|
| 208 |
+
allocator_traits<A>::construct(m, p, rv)
|
| 209 |
```
|
| 210 |
+
|
| 211 |
+
and its evaluation causes the following postcondition to hold: The
|
| 212 |
+
value of `*p` is equivalent to the value of `rv` before the
|
| 213 |
+
evaluation. rv remains a valid object. Its state is unspecified
|
| 214 |
+
- `T` is *`CopyInsertable` into `X`* means that, in addition to `T`
|
| 215 |
+
being `MoveInsertable` into `X`, the following expression is
|
| 216 |
+
well-formed:
|
| 217 |
+
``` cpp
|
| 218 |
+
allocator_traits<A>::construct(m, p, v)
|
| 219 |
+
```
|
| 220 |
+
|
| 221 |
+
and its evaluation causes the following postcondition to hold: The
|
| 222 |
+
value of `v` is unchanged and is equivalent to `*p`.
|
| 223 |
- `T` is *`EmplaceConstructible` into `X` from `args`*, for zero or more
|
| 224 |
arguments `args`, means that the following expression is well-formed:
|
| 225 |
``` cpp
|
| 226 |
+
allocator_traits<A>::construct(m, p, args)
|
| 227 |
+
```
|
| 228 |
+
- `T` is *`Erasable` from `X`* means that the following expression is
|
| 229 |
+
well-formed:
|
| 230 |
+
``` cpp
|
| 231 |
+
allocator_traits<A>::destroy(m, p)
|
| 232 |
```
|
| 233 |
|
| 234 |
A container calls `allocator_traits<A>::construct(m, p, args)` to
|
| 235 |
construct an element at `p` using `args`. The default `construct` in
|
| 236 |
`std::allocator` will call `::new((void*)p) T(args)`, but specialized
|
|
|
|
| 238 |
|
| 239 |
In Table [[tab:containers.allocatoraware]], `X` denotes an
|
| 240 |
allocator-aware container class with a `value_type` of `T` using
|
| 241 |
allocator of type `A`, `u` denotes a variable, `a` and `b` denote
|
| 242 |
non-const lvalues of type `X`, `t` denotes an lvalue or a const rvalue
|
| 243 |
+
of type `X`, `rv` denotes a non-const rvalue of type `X`, and `m` is a
|
| 244 |
+
value of type `A`.
|
| 245 |
|
| 246 |
### Container data races <a id="container.requirements.dataraces">[[container.requirements.dataraces]]</a>
|
| 247 |
|
| 248 |
For purposes of avoiding data races ([[res.on.data.races]]),
|
| 249 |
implementations shall consider the following functions to be `const`:
|
|
|
|
| 251 |
`lower_bound`, `upper_bound`, `equal_range`, `at` and, except in
|
| 252 |
associative or unordered associative containers, `operator[]`.
|
| 253 |
|
| 254 |
Notwithstanding ([[res.on.data.races]]), implementations are required
|
| 255 |
to avoid data races when the contents of the contained object in
|
| 256 |
+
different elements in the same container, excepting `vector<bool>`, are
|
| 257 |
modified concurrently.
|
| 258 |
|
| 259 |
For a `vector<int> x` with a size greater than one, `x[1] = 5` and
|
| 260 |
`*x.begin() = 10` can be executed concurrently without a data race, but
|
| 261 |
`x[0] = 5` and `*x.begin() = 10` executed concurrently may result in a
|
|
|
|
| 314 |
first element inserted into `a`, or `p` if `n == 0`.
|
| 315 |
|
| 316 |
The iterator returned from `a.insert(p, i, j)` points to the copy of the
|
| 317 |
first element inserted into `a`, or `p` if `i == j`.
|
| 318 |
|
| 319 |
+
The iterator returned from `a.insert(p, il)` points to the copy of the
|
| 320 |
+
first element inserted into `a`, or `p` if `il` is empty.
|
| 321 |
|
| 322 |
The iterator returned from `a.emplace(p, args)` points to the new
|
| 323 |
element constructed from `args` into `a`.
|
| 324 |
|
| 325 |
The iterator returned from `a.erase(q)` points to the element
|
|
|
|
| 379 |
`multiset`, `map` and `multimap`.
|
| 380 |
|
| 381 |
Each associative container is parameterized on `Key` and an ordering
|
| 382 |
relation `Compare` that induces a strict weak ordering (
|
| 383 |
[[alg.sorting]]) on elements of `Key`. In addition, `map` and `multimap`
|
| 384 |
+
associate an arbitrary *mapped type* `T` with the `Key`. The object of
|
| 385 |
+
type `Compare` is called the *comparison object* of a container.
|
| 386 |
|
| 387 |
The phrase “equivalence of keys” means the equivalence relation imposed
|
| 388 |
by the comparison and *not* the `operator==` on keys. That is, two keys
|
| 389 |
`k1` and `k2` are considered to be equivalent if for the comparison
|
| 390 |
object `comp`, `comp(k1, k2) == false && comp(k2, k1) == false`. For any
|
|
|
|
| 397 |
`multimap` classes support equivalent keys. For `multiset` and
|
| 398 |
`multimap`, `insert`, `emplace`, and `erase` preserve the relative
|
| 399 |
ordering of equivalent elements.
|
| 400 |
|
| 401 |
For `set` and `multiset` the value type is the same as the key type. For
|
| 402 |
+
`map` and `multimap` it is equal to `pair<const Key, T>`.
|
|
|
|
| 403 |
|
| 404 |
`iterator`
|
| 405 |
|
| 406 |
of an associative container is of the bidirectional iterator category.
|
| 407 |
For associative containers where the value type is the same as the key
|
|
|
|
| 422 |
`CopyAssignable`.
|
| 423 |
|
| 424 |
In Table [[tab:containers.associative.requirements]], `X` denotes an
|
| 425 |
associative container class, `a` denotes a value of `X`, `a_uniq`
|
| 426 |
denotes a value of `X` when `X` supports unique keys, `a_eq` denotes a
|
| 427 |
+
value of `X` when `X` supports multiple keys, `a_tran` denotes a value
|
| 428 |
+
of `X` when the qualified-id `X::key_compare::is_transparent` is valid
|
| 429 |
+
and denotes a type ([[temp.deduct]]), `i` and `j` satisfy input
|
| 430 |
+
iterator requirements and refer to elements implicitly convertible to
|
| 431 |
+
`value_type`, \[`i`, `j`) denotes a valid range, `p` denotes a valid
|
| 432 |
+
const iterator to `a`, `q` denotes a valid dereferenceable const
|
| 433 |
+
iterator to `a`, `[q1, q2)` denotes a valid range of const iterators in
|
| 434 |
+
`a`, `il` designates an object of type `initializer_list<value_type>`,
|
| 435 |
+
`t` denotes a value of `X::value_type`, `k` denotes a value of
|
| 436 |
+
`X::key_type` and `c` denotes a value of type `X::key_compare`; `kl` is
|
| 437 |
+
a value such that `a` is partitioned ([[alg.sorting]]) with respect to
|
| 438 |
+
`c(r, kl)`, with `r` the key value of `e` and `e` in `a`; `ku` is a
|
| 439 |
+
value such that `a` is partitioned with respect to `!c(ku, r)`; `ke` is
|
| 440 |
+
a value such that `a` is partitioned with respect to `c(r, ke)` and
|
| 441 |
+
`!c(ke, r)`, with `c(r, ke)` implying `!c(ke, r)`. `A` denotes the
|
| 442 |
+
storage allocator used by `X`, if any, or
|
| 443 |
+
`std::allocator<X::value_type>` otherwise, and `m` denotes an allocator
|
| 444 |
+
of a type convertible to `A`.
|
| 445 |
|
| 446 |
The `insert` and `emplace` members shall not affect the validity of
|
| 447 |
+
iterators and references to the container, and the `erase` members shall
|
| 448 |
invalidate only iterators and references to the erased elements.
|
| 449 |
|
| 450 |
The fundamental property of iterators of associative containers is that
|
| 451 |
they iterate through the containers in the non-descending order of keys
|
| 452 |
where non-descending is defined by the comparison that was used to
|
|
|
|
| 470 |
associative container is copied, either through a copy constructor or an
|
| 471 |
assignment operator, the target container shall then use the comparison
|
| 472 |
object from the container being copied, as if that comparison object had
|
| 473 |
been passed to the target container in its constructor.
|
| 474 |
|
| 475 |
+
The member function templates `find`, `count`, `lower_bound`,
|
| 476 |
+
`upper_bound`, and `equal_range` shall not participate in overload
|
| 477 |
+
resolution unless the qualified-id `Compare::is_transparent` is valid
|
| 478 |
+
and denotes a type ([[temp.deduct]]).
|
| 479 |
+
|
| 480 |
#### Exception safety guarantees <a id="associative.reqmts.except">[[associative.reqmts.except]]</a>
|
| 481 |
|
| 482 |
For associative containers, no `clear()` function throws an exception.
|
| 483 |
`erase(k)` does not throw an exception unless that exception is thrown
|
| 484 |
by the container’s `Compare` object (if any).
|
|
|
|
| 510 |
of type `Key`, and by a binary predicate `Pred` that induces an
|
| 511 |
equivalence relation on values of type `Key`. Additionally,
|
| 512 |
`unordered_map` and `unordered_multimap` associate an arbitrary *mapped
|
| 513 |
type* `T` with the `Key`.
|
| 514 |
|
| 515 |
+
The container’s object of type `Hash` — denoted by `hash` — is called
|
| 516 |
+
the *hash function* of the container. The container’s object of type
|
| 517 |
+
`Pred` — denoted by `pred` — is called the *key equality predicate* of
|
| 518 |
+
the container.
|
| 519 |
|
| 520 |
Two values `k1` and `k2` of type `Key` are considered equivalent if the
|
| 521 |
+
container’s key equality predicate returns `true` when passed those
|
| 522 |
+
values. If `k1` and `k2` are equivalent, the container’s hash function
|
| 523 |
+
shall return the same value for both. Thus, when an unordered
|
| 524 |
+
associative container is instantiated with a non-default `Pred`
|
| 525 |
+
parameter it usually needs a non-default `Hash` parameter as well. For
|
| 526 |
+
any two keys `k1` and `k2` in the same container, calling `pred(k1, k2)`
|
| 527 |
+
shall always return the same value. For any key `k` in a container,
|
| 528 |
+
calling `hash(k)` shall always return the same value.
|
| 529 |
|
| 530 |
An unordered associative container supports *unique keys* if it may
|
| 531 |
contain at most one element for each key. Otherwise, it supports
|
| 532 |
*equivalent keys*. `unordered_set` and `unordered_map` support unique
|
| 533 |
keys. `unordered_multiset` and `unordered_multimap` support equivalent
|
|
|
|
| 543 |
For `unordered_set` and `unordered_multiset` the value type is the same
|
| 544 |
as the key type. For `unordered_map` and `unordered_multimap` it is
|
| 545 |
`std::pair<const Key,
|
| 546 |
T>`.
|
| 547 |
|
| 548 |
+
For unordered containers where the value type is the same as the key
|
| 549 |
+
type, both `iterator` and `const_iterator` are constant iterators. It is
|
| 550 |
+
unspecified whether or not `iterator` and `const_iterator` are the same
|
| 551 |
+
type. `iterator` and `const_iterator` have identical semantics in this
|
| 552 |
+
case, and `iterator` is convertible to `const_iterator`. Users can avoid
|
| 553 |
+
violating the One Definition Rule by always using `const_iterator` in
|
| 554 |
+
their function parameter lists.
|
| 555 |
+
|
| 556 |
The elements of an unordered associative container are organized into
|
| 557 |
*buckets*. Keys with the same hash code appear in the same bucket. The
|
| 558 |
number of buckets is automatically increased as elements are added to an
|
| 559 |
unordered associative container, so that the average number of elements
|
| 560 |
per bucket is kept below a bound. Rehashing invalidates iterators,
|
|
|
|
| 589 |
|
| 590 |
Two unordered containers `a` and `b` compare equal if
|
| 591 |
`a.size() == b.size()` and, for every equivalent-key group \[`Ea1`,
|
| 592 |
`Ea2`) obtained from `a.equal_range(Ea1)`, there exists an
|
| 593 |
equivalent-key group \[`Eb1`, `Eb2`) obtained from `b.equal_range(Ea1)`,
|
| 594 |
+
such that `is_permutation(Ea1, Ea2, Eb1, Eb2)` returns `true`. For
|
| 595 |
+
`unordered_set` and `unordered_map`, the complexity of `operator==`
|
| 596 |
+
(i.e., the number of calls to the `==` operator of the `value_type`, to
|
| 597 |
+
the predicate returned by `key_equal()`, and to the hasher returned by
|
|
|
|
| 598 |
`hash_function()`) is proportional to N in the average case and to N² in
|
| 599 |
the worst case, where N is a.size(). For `unordered_multiset` and
|
| 600 |
`unordered_multimap`, the complexity of `operator==` is proportional to
|
| 601 |
$\sum E_i^2$ in the average case and to N² in the worst case, where N is
|
| 602 |
`a.size()`, and Eᵢ is the size of the iᵗʰ equivalent-key group in `a`.
|
|
|
|
| 618 |
unordered associative containers where the key type and value type are
|
| 619 |
the same, both `iterator` and `const_iterator` are const iterators.
|
| 620 |
|
| 621 |
The `insert` and `emplace` members shall not affect the validity of
|
| 622 |
references to container elements, but may invalidate all iterators to
|
| 623 |
+
the container. The `erase` members shall invalidate only iterators and
|
| 624 |
+
references to the erased elements, and preserve the relative order of
|
| 625 |
+
the elements that are not erased.
|
| 626 |
|
| 627 |
The `insert` and `emplace` members shall not affect the validity of
|
| 628 |
iterators if `(N+n) < z * B`, where `N` is the number of elements in the
|
| 629 |
container prior to the insert operation, `n` is the number of elements
|
| 630 |
inserted, `B` is the container’s bucket count, and `z` is the
|
|
|
|
| 688 |
template <class T, size_t N>
|
| 689 |
struct tuple_size<array<T, N> >;
|
| 690 |
template <size_t I, class T, size_t N>
|
| 691 |
struct tuple_element<I, array<T, N> >;
|
| 692 |
template <size_t I, class T, size_t N>
|
| 693 |
+
constexpr T& get(array<T, N>&) noexcept;
|
| 694 |
template <size_t I, class T, size_t N>
|
| 695 |
+
constexpr T&& get(array<T, N>&&) noexcept;
|
| 696 |
template <size_t I, class T, size_t N>
|
| 697 |
+
constexpr const T& get(const array<T, N>&) noexcept;
|
| 698 |
}
|
| 699 |
```
|
| 700 |
|
| 701 |
\synopsis{Header \texttt{\<deque\>} synopsis}
|
| 702 |
|
|
|
|
| 795 |
template <class Allocator> class vector<bool,Allocator>;
|
| 796 |
|
| 797 |
// hash support
|
| 798 |
template <class T> struct hash;
|
| 799 |
template <class Allocator> struct hash<vector<bool, Allocator> >;
|
| 800 |
+
}
|
| 801 |
```
|
| 802 |
|
| 803 |
### Class template `array` <a id="array">[[array]]</a>
|
| 804 |
|
| 805 |
#### Class template `array` overview <a id="array.overview">[[array.overview]]</a>
|
|
|
|
| 842 |
typedef size_t size_type;
|
| 843 |
typedef ptrdiff_t difference_type;
|
| 844 |
typedef T value_type;
|
| 845 |
typedef T* pointer;
|
| 846 |
typedef const T* const_pointer;
|
| 847 |
+
typedef std::reverse_iterator<iterator> reverse_iterator;
|
| 848 |
+
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
| 849 |
|
| 850 |
T elems[N]; // exposition only
|
| 851 |
|
| 852 |
// no explicit construct/copy/destroy for aggregate type
|
| 853 |
|
|
|
|
| 869 |
const_iterator cend() const noexcept;
|
| 870 |
const_reverse_iterator crbegin() const noexcept;
|
| 871 |
const_reverse_iterator crend() const noexcept;
|
| 872 |
|
| 873 |
// capacity:
|
| 874 |
+
constexpr size_type size() const noexcept;
|
| 875 |
+
constexpr size_type max_size() const noexcept;
|
| 876 |
+
constexpr bool empty() const noexcept;
|
| 877 |
|
| 878 |
// element access:
|
| 879 |
reference operator[](size_type n);
|
| 880 |
+
constexpr const_reference operator[](size_type n) const;
|
|
|
|
| 881 |
reference at(size_type n);
|
| 882 |
+
constexpr const_reference at(size_type n) const;
|
| 883 |
reference front();
|
| 884 |
+
constexpr const_reference front() const;
|
| 885 |
reference back();
|
| 886 |
+
constexpr const_reference back() const;
|
| 887 |
|
| 888 |
T * data() noexcept;
|
| 889 |
const T * data() const noexcept;
|
| 890 |
};
|
| 891 |
}
|
|
|
|
| 916 |
|
| 917 |
``` cpp
|
| 918 |
x.swap(y);
|
| 919 |
```
|
| 920 |
|
| 921 |
+
*Complexity:* Linear in `N`.
|
| 922 |
|
| 923 |
#### `array::size` <a id="array.size">[[array.size]]</a>
|
| 924 |
|
| 925 |
``` cpp
|
| 926 |
+
template <class T, size_t N> constexpr size_type array<T,N>::size() const noexcept;
|
| 927 |
```
|
| 928 |
|
| 929 |
*Returns:* `N`
|
| 930 |
|
| 931 |
#### `array::data` <a id="array.data">[[array.data]]</a>
|
|
|
|
| 954 |
*Effects:* `swap_ranges(begin(), end(), y.begin())`
|
| 955 |
|
| 956 |
*Throws:* Nothing unless one of the element-wise swap calls throws an
|
| 957 |
exception.
|
| 958 |
|
| 959 |
+
*Note:* Unlike the `swap` function for other containers, `array::swap`
|
| 960 |
takes linear time, may exit via an exception, and does not cause
|
| 961 |
iterators to become associated with the other container.
|
| 962 |
|
| 963 |
#### Zero sized arrays <a id="array.zero">[[array.zero]]</a>
|
| 964 |
|
|
|
|
| 974 |
equivalent to `noexcept(true)`.
|
| 975 |
|
| 976 |
#### Tuple interface to class template `array` <a id="array.tuple">[[array.tuple]]</a>
|
| 977 |
|
| 978 |
``` cpp
|
| 979 |
+
template <class T, size_t N>
|
| 980 |
+
struct tuple_size<array<T, N>>
|
| 981 |
+
: integral_constant<size_t, N> { };
|
| 982 |
```
|
| 983 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 984 |
``` cpp
|
| 985 |
tuple_element<I, array<T, N> >::type
|
| 986 |
```
|
| 987 |
|
| 988 |
*Requires:* `I < N`. The program is ill-formed if `I` is out of bounds.
|
| 989 |
|
| 990 |
*Value:* The type T.
|
| 991 |
|
| 992 |
``` cpp
|
| 993 |
+
template <size_t I, class T, size_t N>
|
| 994 |
+
constexpr T& get(array<T, N>& a) noexcept;
|
| 995 |
```
|
| 996 |
|
| 997 |
*Requires:* `I < N`. The program is ill-formed if `I` is out of bounds.
|
| 998 |
|
| 999 |
*Returns:* A reference to the `I`th element of `a`, where indexing is
|
| 1000 |
zero-based.
|
| 1001 |
|
| 1002 |
``` cpp
|
| 1003 |
+
template <size_t I, class T, size_t N>
|
| 1004 |
+
constexpr T&& get(array<T, N>&& a) noexcept;
|
| 1005 |
```
|
| 1006 |
|
| 1007 |
*Effects:* Equivalent to `return std::move(get<I>(a));`
|
| 1008 |
|
| 1009 |
``` cpp
|
| 1010 |
+
template <size_t I, class T, size_t N>
|
| 1011 |
+
constexpr const T& get(const array<T, N>& a) noexcept;
|
| 1012 |
```
|
| 1013 |
|
| 1014 |
*Requires:* `I < N`. The program is ill-formed if `I` is out of bounds.
|
| 1015 |
|
| 1016 |
*Returns:* A const reference to the `I`th element of `a`, where indexing
|
|
|
|
| 1054 |
typedef typename allocator_traits<Allocator>::const_pointer const_pointer;
|
| 1055 |
typedef std::reverse_iterator<iterator> reverse_iterator;
|
| 1056 |
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
| 1057 |
|
| 1058 |
// [deque.cons], construct/copy/destroy:
|
| 1059 |
+
deque() : deque(Allocator()) { }
|
| 1060 |
+
explicit deque(const Allocator&);
|
| 1061 |
+
explicit deque(size_type n, const Allocator& = Allocator());
|
| 1062 |
deque(size_type n, const T& value, const Allocator& = Allocator());
|
| 1063 |
template <class InputIterator>
|
| 1064 |
deque(InputIterator first, InputIterator last, const Allocator& = Allocator());
|
| 1065 |
deque(const deque& x);
|
| 1066 |
deque(deque&&);
|
|
|
|
| 1157 |
```
|
| 1158 |
|
| 1159 |
#### `deque` constructors, copy, and assignment <a id="deque.cons">[[deque.cons]]</a>
|
| 1160 |
|
| 1161 |
``` cpp
|
| 1162 |
+
explicit deque(const Allocator&);
|
| 1163 |
```
|
| 1164 |
|
| 1165 |
*Effects:* Constructs an empty `deque`, using the specified allocator.
|
| 1166 |
|
| 1167 |
*Complexity:* Constant.
|
| 1168 |
|
| 1169 |
``` cpp
|
| 1170 |
+
explicit deque(size_type n, const Allocator& = Allocator());
|
| 1171 |
```
|
| 1172 |
|
| 1173 |
+
*Effects:* Constructs a `deque` with `n` default-inserted elements using
|
| 1174 |
+
the specified allocator.
|
| 1175 |
|
| 1176 |
+
*Requires:* `T` shall be `DefaultInsertable` into `*this`.
|
| 1177 |
|
| 1178 |
*Complexity:* Linear in `n`.
|
| 1179 |
|
| 1180 |
``` cpp
|
| 1181 |
deque(size_type n, const T& value,
|
|
|
|
| 1196 |
```
|
| 1197 |
|
| 1198 |
*Effects:* Constructs a `deque` equal to the range \[`first`, `last`),
|
| 1199 |
using the specified allocator.
|
| 1200 |
|
| 1201 |
+
*Complexity:* Linear in `distance(first, last)`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1202 |
|
| 1203 |
#### `deque` capacity <a id="deque.capacity">[[deque.capacity]]</a>
|
| 1204 |
|
| 1205 |
``` cpp
|
| 1206 |
void resize(size_type sz);
|
| 1207 |
```
|
| 1208 |
|
| 1209 |
+
*Effects:* If `sz <= size()`, equivalent to calling `pop_back()`
|
| 1210 |
+
`size() - sz` times. If `size() < sz`, appends `sz - size()`
|
| 1211 |
+
default-inserted elements to the sequence.
|
| 1212 |
|
| 1213 |
+
*Requires:* `T` shall be `MoveInsertable` and `DefaultInsertable` into
|
| 1214 |
+
`*this`.
|
| 1215 |
|
| 1216 |
``` cpp
|
| 1217 |
void resize(size_type sz, const T& c);
|
| 1218 |
```
|
| 1219 |
|
| 1220 |
+
*Effects:* If `sz <= size()`, equivalent to calling `pop_back()`
|
| 1221 |
+
`size() - sz` times. If `size() < sz`, appends `sz - size()` copies of
|
| 1222 |
+
`c` to the sequence.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1223 |
|
| 1224 |
*Requires:* `T` shall be `CopyInsertable` into `*this`.
|
| 1225 |
|
| 1226 |
``` cpp
|
| 1227 |
void shrink_to_fit();
|
| 1228 |
```
|
| 1229 |
|
| 1230 |
+
*Requires:* `T` shall be `MoveInsertable` into `*this`.
|
| 1231 |
+
|
| 1232 |
+
*Complexity:* Linear in the size of the sequence.
|
| 1233 |
+
|
| 1234 |
+
*Remarks:* `shrink_to_fit` is a non-binding request to reduce memory use
|
| 1235 |
+
but does not change the size of the sequence. The request is non-binding
|
| 1236 |
+
to allow latitude for implementation-specific optimizations.
|
| 1237 |
|
| 1238 |
#### `deque` modifiers <a id="deque.modifiers">[[deque.modifiers]]</a>
|
| 1239 |
|
| 1240 |
``` cpp
|
| 1241 |
iterator insert(const_iterator position, const T& x);
|
|
|
|
| 1260 |
either end of the deque invalidates all the iterators to the deque, but
|
| 1261 |
has no effect on the validity of references to elements of the deque.
|
| 1262 |
|
| 1263 |
*Remarks:* If an exception is thrown other than by the copy constructor,
|
| 1264 |
move constructor, assignment operator, or move assignment operator of
|
| 1265 |
+
`T` there are no effects. If an exception is thrown while inserting a
|
| 1266 |
+
single element at either end, there are no effects. Otherwise, if an
|
| 1267 |
+
exception is thrown by the move constructor of a non-`CopyInsertable`
|
| 1268 |
+
`T`, the effects are unspecified.
|
| 1269 |
|
| 1270 |
*Complexity:* The complexity is linear in the number of elements
|
| 1271 |
inserted plus the lesser of the distances to the beginning and end of
|
| 1272 |
the deque. Inserting a single element either at the beginning or end of
|
| 1273 |
a deque always takes constant time and causes a single call to a
|
|
|
|
| 1321 |
hand-written C-style singly linked list. Features that would conflict
|
| 1322 |
with that goal have been omitted.
|
| 1323 |
|
| 1324 |
A `forward_list` satisfies all of the requirements of a container
|
| 1325 |
(Table [[tab:containers.container.requirements]]), except that the
|
| 1326 |
+
`size()` member function is not provided and `operator==` has linear
|
| 1327 |
+
complexity. A `forward_list` also satisfies all of the requirements for
|
| 1328 |
+
an allocator-aware container (Table [[tab:containers.allocatoraware]]).
|
| 1329 |
+
In addition, a `forward_list` provides the `assign` member functions
|
| 1330 |
+
(Table [[tab:containers.sequence.requirements]]) and several of the
|
| 1331 |
+
optional container requirements (Table
|
| 1332 |
+
[[tab:containers.sequence.optional]]). Descriptions are provided here
|
| 1333 |
+
only for operations on `forward_list` that are not described in that
|
| 1334 |
+
table or for operations where there is additional semantic information.
|
| 1335 |
|
| 1336 |
Modifying any list requires access to the element preceding the first
|
| 1337 |
element of interest, but in a `forward_list` there is no constant-time
|
| 1338 |
+
way to access a preceding element. For this reason, ranges that are
|
| 1339 |
modified, such as those supplied to `erase` and `splice`, must be open
|
| 1340 |
at the beginning.
|
| 1341 |
|
| 1342 |
``` cpp
|
| 1343 |
namespace std {
|
|
|
|
| 1355 |
typedef Allocator allocator_type;
|
| 1356 |
typedef typename allocator_traits<Allocator>::pointer pointer;
|
| 1357 |
typedef typename allocator_traits<Allocator>::const_pointer const_pointer;
|
| 1358 |
|
| 1359 |
// [forwardlist.cons], construct/copy/destroy:
|
| 1360 |
+
forward_list() : forward_list(Allocator()) { }
|
| 1361 |
+
explicit forward_list(const Allocator&);
|
| 1362 |
+
explicit forward_list(size_type n, const Allocator& = Allocator());
|
| 1363 |
forward_list(size_type n, const T& value,
|
| 1364 |
const Allocator& = Allocator());
|
| 1365 |
template <class InputIterator>
|
| 1366 |
forward_list(InputIterator first, InputIterator last,
|
| 1367 |
const Allocator& = Allocator());
|
|
|
|
| 1473 |
```
|
| 1474 |
|
| 1475 |
#### `forward_list` constructors, copy, assignment <a id="forwardlist.cons">[[forwardlist.cons]]</a>
|
| 1476 |
|
| 1477 |
``` cpp
|
| 1478 |
+
explicit forward_list(const Allocator&);
|
| 1479 |
```
|
| 1480 |
|
| 1481 |
*Effects:* Constructs an empty `forward_list` object using the specified
|
| 1482 |
allocator.
|
| 1483 |
|
| 1484 |
*Complexity:* Constant.
|
| 1485 |
|
| 1486 |
``` cpp
|
| 1487 |
+
explicit forward_list(size_type n, const Allocator& = Allocator());
|
| 1488 |
```
|
| 1489 |
|
| 1490 |
+
*Effects:* Constructs a `forward_list` object with `n` default-inserted
|
| 1491 |
+
elements using the specified allocator.
|
| 1492 |
|
| 1493 |
+
*Requires:* `T` shall be `DefaultInsertable` into `*this`.
|
| 1494 |
|
| 1495 |
*Complexity:* Linear in `n`.
|
| 1496 |
|
| 1497 |
``` cpp
|
| 1498 |
forward_list(size_type n, const T& value, const Allocator& = Allocator());
|
|
|
|
| 1513 |
*Effects:* Constructs a `forward_list` object equal to the range
|
| 1514 |
\[`first`, `last`).
|
| 1515 |
|
| 1516 |
*Complexity:* Linear in `distance(first, last)`.
|
| 1517 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1518 |
#### `forward_list` iterators <a id="forwardlist.iter">[[forwardlist.iter]]</a>
|
| 1519 |
|
| 1520 |
``` cpp
|
| 1521 |
iterator before_begin() noexcept;
|
| 1522 |
const_iterator before_begin() const noexcept;
|
|
|
|
| 1615 |
```
|
| 1616 |
|
| 1617 |
*Effects:* `insert_after(p, il.begin(), il.end())`.
|
| 1618 |
|
| 1619 |
*Returns:* An iterator pointing to the last inserted element or
|
| 1620 |
+
`position` if `il` is empty.
|
| 1621 |
|
| 1622 |
``` cpp
|
| 1623 |
template <class... Args>
|
| 1624 |
iterator emplace_after(const_iterator position, Args&&... args);
|
| 1625 |
```
|
|
|
|
| 1659 |
|
| 1660 |
*Throws:* Nothing.
|
| 1661 |
|
| 1662 |
``` cpp
|
| 1663 |
void resize(size_type sz);
|
| 1664 |
+
```
|
| 1665 |
+
|
| 1666 |
+
*Effects:* If `sz < distance(begin(), end())`, erases the last
|
| 1667 |
+
`distance(begin(), end()) - sz` elements from the list. Otherwise,
|
| 1668 |
+
inserts `sz - distance(begin(), end())` default-inserted elements at the
|
| 1669 |
+
end of the list.
|
| 1670 |
+
|
| 1671 |
+
*Requires:* `T` shall be `DefaultInsertable` into `*this`.
|
| 1672 |
+
|
| 1673 |
+
``` cpp
|
| 1674 |
void resize(size_type sz, const value_type& c);
|
| 1675 |
```
|
| 1676 |
|
| 1677 |
*Effects:* If `sz < distance(begin(), end())`, erases the last
|
| 1678 |
`distance(begin(), end()) - sz` elements from the list. Otherwise,
|
| 1679 |
+
inserts `sz - distance(begin(), end())` elements at the end of the list
|
| 1680 |
+
such that each new element, `e`, is initialized by a method equivalent
|
| 1681 |
+
to calling
|
| 1682 |
+
`allocator_traits<allocator_type>::construct(get_allocator(), std::addressof(e), c)`.
|
| 1683 |
|
| 1684 |
+
*Requires:* `T` shall be `CopyInsertable` into `*this`.
|
|
|
|
| 1685 |
|
| 1686 |
``` cpp
|
| 1687 |
void clear() noexcept;
|
| 1688 |
```
|
| 1689 |
|
|
|
|
| 1697 |
void splice_after(const_iterator position, forward_list& x);
|
| 1698 |
void splice_after(const_iterator position, forward_list&& x);
|
| 1699 |
```
|
| 1700 |
|
| 1701 |
*Requires:* `position` is `before_begin()` or is a dereferenceable
|
| 1702 |
+
iterator in the range \[`begin()`, `end()`).
|
| 1703 |
+
`get_allocator() == x.get_allocator()`. `&x != this`.
|
| 1704 |
|
| 1705 |
*Effects:* Inserts the contents of `x` after `position`, and `x` becomes
|
| 1706 |
empty. Pointers and references to the moved elements of `x` now refer to
|
| 1707 |
those same elements but as members of `*this`. Iterators referring to
|
| 1708 |
the moved elements will continue to refer to their elements, but they
|
|
|
|
| 1718 |
```
|
| 1719 |
|
| 1720 |
*Requires:* `position` is `before_begin()` or is a dereferenceable
|
| 1721 |
iterator in the range \[`begin()`, `end()`). The iterator following `i`
|
| 1722 |
is a dereferenceable iterator in `x`.
|
| 1723 |
+
`get_allocator() == x.get_allocator()`.
|
| 1724 |
|
| 1725 |
*Effects:* Inserts the element following `i` into `*this`, following
|
| 1726 |
`position`, and removes it from `x`. The result is unchanged if
|
| 1727 |
+
`position == i` or `position == ++i`. Pointers and references to `*++i`
|
| 1728 |
continue to refer to the same element but as a member of `*this`.
|
| 1729 |
+
Iterators to `*++i` continue to refer to the same element, but now
|
| 1730 |
+
behave as iterators into `*this`, not into `x`.
|
| 1731 |
|
| 1732 |
*Throws:* Nothing.
|
| 1733 |
|
| 1734 |
*Complexity:* 𝑂(1)
|
| 1735 |
|
|
|
|
| 1742 |
|
| 1743 |
*Requires:* `position` is `before_begin()` or is a dereferenceable
|
| 1744 |
iterator in the range \[`begin()`, `end()`). (`first`, `last`) is a
|
| 1745 |
valid range in `x`, and all iterators in the range (`first`, `last`) are
|
| 1746 |
dereferenceable. `position` is not an iterator in the range (`first`,
|
| 1747 |
+
`last`). `get_allocator() == x.get_allocator()`.
|
| 1748 |
|
| 1749 |
*Effects:* Inserts elements in the range (`first`, `last`) after
|
| 1750 |
`position` and removes the elements from `x`. Pointers and references to
|
| 1751 |
the moved elements of `x` now refer to those same elements but as
|
| 1752 |
members of `*this`. Iterators referring to the moved elements will
|
|
|
|
| 1760 |
template <class Predicate> void remove_if(Predicate pred);
|
| 1761 |
```
|
| 1762 |
|
| 1763 |
*Effects:* Erases all the elements in the list referred by a list
|
| 1764 |
iterator `i` for which the following conditions hold: `*i == value` (for
|
| 1765 |
+
`remove()`), `pred(*i)` is true (for `remove_if()`). Invalidates only
|
| 1766 |
+
the iterators and references to the erased elements.
|
|
|
|
|
|
|
| 1767 |
|
| 1768 |
*Throws:* Nothing unless an exception is thrown by the equality
|
| 1769 |
comparison or the predicate.
|
| 1770 |
|
| 1771 |
+
*Remarks:* Stable ([[algorithm.stable]]).
|
| 1772 |
+
|
| 1773 |
*Complexity:* Exactly `distance(begin(), end())` applications of the
|
| 1774 |
corresponding predicate.
|
| 1775 |
|
| 1776 |
``` cpp
|
| 1777 |
void unique();
|
|
|
|
| 1793 |
otherwise no applications of the predicate.
|
| 1794 |
|
| 1795 |
``` cpp
|
| 1796 |
void merge(forward_list& x);
|
| 1797 |
void merge(forward_list&& x);
|
| 1798 |
+
template <class Compare> void merge(forward_list& x, Compare comp);
|
| 1799 |
+
template <class Compare> void merge(forward_list&& x, Compare comp);
|
| 1800 |
```
|
| 1801 |
|
| 1802 |
*Requires:* `comp` defines a strict weak ordering ([[alg.sorting]]),
|
| 1803 |
and `*this` and `x` are both sorted according to this ordering.
|
| 1804 |
+
`get_allocator() == x.get_allocator()`.
|
| 1805 |
|
| 1806 |
+
*Effects:* Merges the two sorted ranges `[begin(), end())` and
|
| 1807 |
+
`[x.begin(), x.end())`. `x` is empty after the merge. If an exception is
|
| 1808 |
+
thrown other than by a comparison there are no effects. Pointers and
|
| 1809 |
+
references to the moved elements of `x` now refer to those same elements
|
| 1810 |
+
but as members of `*this`. Iterators referring to the moved elements
|
| 1811 |
+
will continue to refer to their elements, but they now behave as
|
| 1812 |
+
iterators into `*this`, not into `x`.
|
|
|
|
| 1813 |
|
| 1814 |
+
*Remarks:* Stable ([[algorithm.stable]]). The behavior is undefined if
|
| 1815 |
+
`this->get_allocator() != x.get_allocator()`.
|
| 1816 |
+
|
| 1817 |
+
*Complexity:* At most
|
| 1818 |
+
`distance(begin(), end()) + distance(x.begin(), x.end()) - 1`
|
| 1819 |
+
comparisons.
|
| 1820 |
|
| 1821 |
``` cpp
|
| 1822 |
void sort();
|
| 1823 |
template <class Compare> void sort(Compare comp);
|
| 1824 |
```
|
|
|
|
| 1826 |
*Requires:* `operator<` (for the version with no arguments) or `comp`
|
| 1827 |
(for the version with a comparison argument) defines a strict weak
|
| 1828 |
ordering ([[alg.sorting]]).
|
| 1829 |
|
| 1830 |
*Effects:* Sorts the list according to the `operator<` or the `comp`
|
| 1831 |
+
function object. If an exception is thrown the order of the elements in
|
| 1832 |
+
`*this` is unspecified. Does not affect the validity of iterators and
|
| 1833 |
+
references.
|
| 1834 |
+
|
| 1835 |
+
*Remarks:* Stable ([[algorithm.stable]]).
|
| 1836 |
|
| 1837 |
*Complexity:* Approximately N log N comparisons, where N is
|
| 1838 |
`distance(begin(), end())`.
|
| 1839 |
|
| 1840 |
``` cpp
|
|
|
|
| 1895 |
typedef typename allocator_traits<Allocator>::const_pointer const_pointer;
|
| 1896 |
typedef std::reverse_iterator<iterator> reverse_iterator;
|
| 1897 |
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
| 1898 |
|
| 1899 |
// [list.cons], construct/copy/destroy:
|
| 1900 |
+
list() : list(Allocator()) { }
|
| 1901 |
+
explicit list(const Allocator&);
|
| 1902 |
+
explicit list(size_type n, const Allocator& = Allocator());
|
| 1903 |
list(size_type n, const T& value, const Allocator& = Allocator());
|
| 1904 |
template <class InputIterator>
|
| 1905 |
list(InputIterator first, InputIterator last, const Allocator& = Allocator());
|
| 1906 |
list(const list& x);
|
| 1907 |
list(list&& x);
|
|
|
|
| 2018 |
```
|
| 2019 |
|
| 2020 |
#### `list` constructors, copy, and assignment <a id="list.cons">[[list.cons]]</a>
|
| 2021 |
|
| 2022 |
``` cpp
|
| 2023 |
+
explicit list(const Allocator&);
|
| 2024 |
```
|
| 2025 |
|
| 2026 |
*Effects:* Constructs an empty list, using the specified allocator.
|
| 2027 |
|
| 2028 |
*Complexity:* Constant.
|
| 2029 |
|
| 2030 |
``` cpp
|
| 2031 |
+
explicit list(size_type n, const Allocator& = Allocator());
|
| 2032 |
```
|
| 2033 |
|
| 2034 |
+
*Effects:* Constructs a `list` with `n` default-inserted elements using
|
| 2035 |
+
the specified allocator.
|
| 2036 |
|
| 2037 |
+
*Requires:* `T` shall be `DefaultInsertable` into `*this`.
|
| 2038 |
|
| 2039 |
*Complexity:* Linear in `n`.
|
| 2040 |
|
| 2041 |
``` cpp
|
| 2042 |
list(size_type n, const T& value,
|
|
|
|
| 2058 |
|
| 2059 |
*Effects:* Constructs a `list` equal to the range \[`first`, `last`).
|
| 2060 |
|
| 2061 |
*Complexity:* Linear in `distance(first, last)`.
|
| 2062 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2063 |
#### `list` capacity <a id="list.capacity">[[list.capacity]]</a>
|
| 2064 |
|
| 2065 |
``` cpp
|
| 2066 |
void resize(size_type sz);
|
| 2067 |
```
|
| 2068 |
|
| 2069 |
+
*Effects:* If `size() < sz`, appends `sz - size()` default-inserted
|
| 2070 |
elements to the sequence. If `sz <= size()`, equivalent to
|
| 2071 |
|
| 2072 |
``` cpp
|
| 2073 |
list<T>::iterator it = begin();
|
| 2074 |
advance(it, sz);
|
| 2075 |
erase(it, end());
|
| 2076 |
```
|
| 2077 |
|
| 2078 |
+
*Requires:* `T` shall be `DefaultInsertable` into `*this`.
|
| 2079 |
|
| 2080 |
``` cpp
|
| 2081 |
void resize(size_type sz, const T& c);
|
| 2082 |
```
|
| 2083 |
|
|
|
|
| 2222 |
references to the erased elements.
|
| 2223 |
|
| 2224 |
*Throws:* Nothing unless an exception is thrown by `*i == value` or
|
| 2225 |
`pred(*i) != false`.
|
| 2226 |
|
| 2227 |
+
*Remarks:* Stable ([[algorithm.stable]]).
|
| 2228 |
|
| 2229 |
*Complexity:* Exactly `size()` applications of the corresponding
|
| 2230 |
predicate.
|
| 2231 |
|
| 2232 |
``` cpp
|
|
|
|
| 2239 |
\[`first + 1`, `last`) for which `*i == *(i-1)` (for the version of
|
| 2240 |
`unique` with no arguments) or `pred(*i, *(i - 1))` (for the version of
|
| 2241 |
`unique` with a predicate argument) holds. Invalidates only the
|
| 2242 |
iterators and references to the erased elements.
|
| 2243 |
|
| 2244 |
+
*Throws:* Nothing unless an exception is thrown by `*i == *(i-1)` or
|
| 2245 |
`pred(*i, *(i - 1))`
|
| 2246 |
|
| 2247 |
*Complexity:* If the range `[first, last)` is not empty, exactly
|
| 2248 |
`(last - first) - 1` applications of the corresponding predicate,
|
| 2249 |
otherwise no applications of the predicate.
|
|
|
|
| 2268 |
elements of `x` now refer to those same elements but as members of
|
| 2269 |
`*this`. Iterators referring to the moved elements will continue to
|
| 2270 |
refer to their elements, but they now behave as iterators into `*this`,
|
| 2271 |
not into `x`.
|
| 2272 |
|
| 2273 |
+
*Remarks:* Stable ([[algorithm.stable]]). If `(&x != this)` the range
|
| 2274 |
+
`[x.begin(), x.end())` is empty after the merge. No elements are copied
|
| 2275 |
+
by this operation. The behavior is undefined if
|
| 2276 |
+
`this->get_allocator() != x.get_allocator()`.
|
| 2277 |
|
| 2278 |
*Complexity:* At most `size() + x.size() - 1` applications of `comp` if
|
| 2279 |
`(&x != this)`; otherwise, no applications of `comp` are performed. If
|
| 2280 |
an exception is thrown other than by a comparison there are no effects.
|
| 2281 |
|
|
|
|
| 2298 |
|
| 2299 |
*Effects:* Sorts the list according to the `operator<` or a `Compare`
|
| 2300 |
function object. Does not affect the validity of iterators and
|
| 2301 |
references.
|
| 2302 |
|
| 2303 |
+
*Remarks:* Stable ([[algorithm.stable]]).
|
| 2304 |
|
| 2305 |
*Complexity:* Approximately N log(N) comparisons, where `N == size()`.
|
| 2306 |
|
| 2307 |
#### `list` specialized algorithms <a id="list.special">[[list.special]]</a>
|
| 2308 |
|
|
|
|
| 2359 |
typedef typename allocator_traits<Allocator>::const_pointer const_pointer;
|
| 2360 |
typedef std::reverse_iterator<iterator> reverse_iterator;
|
| 2361 |
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
| 2362 |
|
| 2363 |
// [vector.cons], construct/copy/destroy:
|
| 2364 |
+
vector() : vector(Allocator()) { }
|
| 2365 |
+
explicit vector(const Allocator&);
|
| 2366 |
+
explicit vector(size_type n, const Allocator& = Allocator());
|
| 2367 |
vector(size_type n, const T& value, const Allocator& = Allocator());
|
| 2368 |
template <class InputIterator>
|
| 2369 |
vector(InputIterator first, InputIterator last,
|
| 2370 |
const Allocator& = Allocator());
|
| 2371 |
vector(const vector& x);
|
|
|
|
| 2462 |
```
|
| 2463 |
|
| 2464 |
#### `vector` constructors, copy, and assignment <a id="vector.cons">[[vector.cons]]</a>
|
| 2465 |
|
| 2466 |
``` cpp
|
| 2467 |
+
explicit vector(const Allocator&);
|
| 2468 |
```
|
| 2469 |
|
| 2470 |
*Effects:* Constructs an empty `vector`, using the specified allocator.
|
| 2471 |
|
| 2472 |
*Complexity:* Constant.
|
| 2473 |
|
| 2474 |
``` cpp
|
| 2475 |
+
explicit vector(size_type n, const Allocator& = Allocator());
|
| 2476 |
```
|
| 2477 |
|
| 2478 |
+
*Effects:* Constructs a `vector` with `n` default-inserted elements
|
| 2479 |
+
using the specified allocator.
|
| 2480 |
|
| 2481 |
+
*Requires:* `T` shall be `DefaultInsertable` into `*this`.
|
| 2482 |
|
| 2483 |
*Complexity:* Linear in `n`.
|
| 2484 |
|
| 2485 |
``` cpp
|
| 2486 |
vector(size_type n, const T& value,
|
|
|
|
| 2507 |
is the distance between `first` and `last`) and no reallocations if
|
| 2508 |
iterators first and last are of forward, bidirectional, or random access
|
| 2509 |
categories. It makes order `N` calls to the copy constructor of `T` and
|
| 2510 |
order log(N) reallocations if they are just input iterators.
|
| 2511 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2512 |
#### `vector` capacity <a id="vector.capacity">[[vector.capacity]]</a>
|
| 2513 |
|
| 2514 |
``` cpp
|
| 2515 |
size_type capacity() const noexcept;
|
| 2516 |
```
|
|
|
|
| 2520 |
|
| 2521 |
``` cpp
|
| 2522 |
void reserve(size_type n);
|
| 2523 |
```
|
| 2524 |
|
| 2525 |
+
*Requires:* `T` shall be `MoveInsertable` into `*this`.
|
| 2526 |
+
|
| 2527 |
*Effects:* A directive that informs a `vector` of a planned change in
|
| 2528 |
size, so that it can manage the storage allocation accordingly. After
|
| 2529 |
`reserve()`, `capacity()` is greater or equal to the argument of
|
| 2530 |
`reserve` if reallocation happens; and equal to the previous value of
|
| 2531 |
`capacity()` otherwise. Reallocation happens at this point if and only
|
|
|
|
| 2537 |
most linear time in the size of the sequence.
|
| 2538 |
|
| 2539 |
*Throws:* `length_error` if `n > max_size()`.[^4]
|
| 2540 |
|
| 2541 |
*Remarks:* Reallocation invalidates all the references, pointers, and
|
| 2542 |
+
iterators referring to the elements in the sequence. No reallocation
|
| 2543 |
+
shall take place during insertions that happen after a call to
|
| 2544 |
+
`reserve()` until the time when an insertion would make the size of the
|
| 2545 |
+
vector greater than the value of `capacity()`.
|
| 2546 |
|
| 2547 |
``` cpp
|
| 2548 |
void shrink_to_fit();
|
| 2549 |
```
|
| 2550 |
|
| 2551 |
+
*Requires:* `T` shall be `MoveInsertable` into `*this`.
|
| 2552 |
+
|
| 2553 |
+
*Complexity:* Linear in the size of the sequence.
|
| 2554 |
+
|
| 2555 |
*Remarks:* `shrink_to_fit` is a non-binding request to reduce
|
| 2556 |
`capacity()` to `size()`. The request is non-binding to allow latitude
|
| 2557 |
+
for implementation-specific optimizations. If an exception is thrown
|
| 2558 |
+
other than by the move constructor of a non-`CopyInsertable` `T` there
|
| 2559 |
+
are no effects.
|
| 2560 |
|
| 2561 |
``` cpp
|
| 2562 |
void swap(vector& x);
|
| 2563 |
```
|
| 2564 |
|
|
|
|
| 2569 |
|
| 2570 |
``` cpp
|
| 2571 |
void resize(size_type sz);
|
| 2572 |
```
|
| 2573 |
|
| 2574 |
+
*Effects:* If `sz <= size()`, equivalent to calling `pop_back()`
|
| 2575 |
+
`size() - sz` times. If `size() < sz`, appends `sz - size()`
|
| 2576 |
+
default-inserted elements to the sequence.
|
| 2577 |
|
| 2578 |
+
*Requires:* `T` shall be `MoveInsertable` and `DefaultInsertable` into
|
| 2579 |
+
`*this`.
|
| 2580 |
|
| 2581 |
+
*Remarks:* If an exception is thrown other than by the move constructor
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2582 |
of a non-`CopyInsertable` `T` there are no effects.
|
| 2583 |
|
| 2584 |
+
``` cpp
|
| 2585 |
+
void resize(size_type sz, const T& c);
|
| 2586 |
+
```
|
| 2587 |
+
|
| 2588 |
+
*Effects:* If `sz <= size()`, equivalent to calling `pop_back()`
|
| 2589 |
+
`size() - sz` times. If `size() < sz`, appends `sz - size()` copies of
|
| 2590 |
+
`c` to the sequence.
|
| 2591 |
+
|
| 2592 |
+
*Requires:* `T` shall be `CopyInsertable` into `*this`.
|
| 2593 |
+
|
| 2594 |
+
*Remarks:* If an exception is thrown there are no effects.
|
| 2595 |
+
|
| 2596 |
#### `vector` data <a id="vector.data">[[vector.data]]</a>
|
| 2597 |
|
| 2598 |
``` cpp
|
| 2599 |
T* data() noexcept;
|
| 2600 |
const T* data() const noexcept;
|
|
|
|
| 2624 |
*Remarks:* Causes reallocation if the new size is greater than the old
|
| 2625 |
capacity. If no reallocation happens, all the iterators and references
|
| 2626 |
before the insertion point remain valid. If an exception is thrown other
|
| 2627 |
than by the copy constructor, move constructor, assignment operator, or
|
| 2628 |
move assignment operator of `T` or by any `InputIterator` operation
|
| 2629 |
+
there are no effects. If an exception is thrown while inserting a single
|
| 2630 |
+
element at the end and `T` is `CopyInsertable` or
|
| 2631 |
+
`is_nothrow_move_constructible<T>::value` is `true`, there are no
|
| 2632 |
+
effects. Otherwise, if an exception is thrown by the move constructor of
|
| 2633 |
+
a non-`CopyInsertable` `T`, the effects are unspecified.
|
| 2634 |
|
| 2635 |
*Complexity:* The complexity is linear in the number of elements
|
| 2636 |
inserted plus the distance to the end of the vector.
|
| 2637 |
|
| 2638 |
``` cpp
|
|
|
|
| 2698 |
reference& operator=(const reference& x) noexcept;
|
| 2699 |
void flip() noexcept; // flips the bit
|
| 2700 |
};
|
| 2701 |
|
| 2702 |
// construct/copy/destroy:
|
| 2703 |
+
vector() : vector(Allocator()) { }
|
| 2704 |
+
explicit vector(const Allocator&);
|
| 2705 |
+
explicit vector(size_type n, const Allocator& = Allocator());
|
| 2706 |
+
vector(size_type n, const bool& value,
|
| 2707 |
const Allocator& = Allocator());
|
| 2708 |
template <class InputIterator>
|
| 2709 |
vector(InputIterator first, InputIterator last,
|
| 2710 |
const Allocator& = Allocator());
|
| 2711 |
vector(const vector<bool,Allocator>& x);
|
|
|
|
| 2714 |
vector(vector&&, const Allocator&);
|
| 2715 |
vector(initializer_list<bool>, const Allocator& = Allocator()));
|
| 2716 |
~vector();
|
| 2717 |
vector<bool,Allocator>& operator=(const vector<bool,Allocator>& x);
|
| 2718 |
vector<bool,Allocator>& operator=(vector<bool,Allocator>&& x);
|
| 2719 |
+
vector& operator=(initializer_list<bool>);
|
| 2720 |
template <class InputIterator>
|
| 2721 |
void assign(InputIterator first, InputIterator last);
|
| 2722 |
void assign(size_type n, const bool& t);
|
| 2723 |
+
void assign(initializer_list<bool>);
|
| 2724 |
allocator_type get_allocator() const noexcept;
|
| 2725 |
|
| 2726 |
// iterators:
|
| 2727 |
iterator begin() noexcept;
|
| 2728 |
const_iterator begin() const noexcept;
|
|
|
|
| 2756 |
const_reference front() const;
|
| 2757 |
reference back();
|
| 2758 |
const_reference back() const;
|
| 2759 |
|
| 2760 |
// modifiers:
|
| 2761 |
+
template <class... Args> void emplace_back(Args&&... args);
|
| 2762 |
void push_back(const bool& x);
|
| 2763 |
void pop_back();
|
| 2764 |
+
template <class... Args> iterator emplace(const_iterator position, Args&&... args);
|
| 2765 |
iterator insert(const_iterator position, const bool& x);
|
| 2766 |
iterator insert (const_iterator position, size_type n, const bool& x);
|
| 2767 |
template <class InputIterator>
|
| 2768 |
iterator insert(const_iterator position,
|
| 2769 |
InputIterator first, InputIterator last);
|
|
|
|
| 2817 |
|
| 2818 |
``` cpp
|
| 2819 |
template <class Allocator> struct hash<vector<bool, Allocator> >;
|
| 2820 |
```
|
| 2821 |
|
| 2822 |
+
The template specialization shall meet the requirements of class
|
| 2823 |
+
template `hash` ([[unord.hash]]).
|
| 2824 |
|
| 2825 |
## Associative containers <a id="associative">[[associative]]</a>
|
| 2826 |
|
| 2827 |
### In general <a id="associative.general">[[associative.general]]</a>
|
| 2828 |
|
|
|
|
| 3004 |
return comp(x.first, y.first);
|
| 3005 |
}
|
| 3006 |
};
|
| 3007 |
|
| 3008 |
// [map.cons], construct/copy/destroy:
|
| 3009 |
+
map() : map(Compare()) { }
|
| 3010 |
+
explicit map(const Compare& comp,
|
| 3011 |
const Allocator& = Allocator());
|
| 3012 |
template <class InputIterator>
|
| 3013 |
map(InputIterator first, InputIterator last,
|
| 3014 |
const Compare& comp = Compare(), const Allocator& = Allocator());
|
| 3015 |
+
map(const map& x);
|
| 3016 |
+
map(map&& x);
|
| 3017 |
explicit map(const Allocator&);
|
| 3018 |
map(const map&, const Allocator&);
|
| 3019 |
map(map&&, const Allocator&);
|
| 3020 |
map(initializer_list<value_type>,
|
| 3021 |
const Compare& = Compare(),
|
| 3022 |
const Allocator& = Allocator());
|
| 3023 |
+
template <class InputIterator>
|
| 3024 |
+
map(InputIterator first, InputIterator last, const Allocator& a)
|
| 3025 |
+
: map(first, last, Compare(), a) { }
|
| 3026 |
+
map(initializer_list<value_type> il, const Allocator& a)
|
| 3027 |
+
: map(il, Compare(), a) { }
|
| 3028 |
~map();
|
| 3029 |
+
map& operator=(const map& x);
|
| 3030 |
+
map& operator=(map&& x);
|
|
|
|
|
|
|
| 3031 |
map& operator=(initializer_list<value_type>);
|
| 3032 |
allocator_type get_allocator() const noexcept;
|
| 3033 |
|
| 3034 |
// iterators:
|
| 3035 |
iterator begin() noexcept;
|
|
|
|
| 3071 |
void insert(initializer_list<value_type>);
|
| 3072 |
|
| 3073 |
iterator erase(const_iterator position);
|
| 3074 |
size_type erase(const key_type& x);
|
| 3075 |
iterator erase(const_iterator first, const_iterator last);
|
| 3076 |
+
void swap(map&);
|
| 3077 |
void clear() noexcept;
|
| 3078 |
|
| 3079 |
// observers:
|
| 3080 |
key_compare key_comp() const;
|
| 3081 |
value_compare value_comp() const;
|
| 3082 |
|
| 3083 |
+
// map operations:
|
| 3084 |
iterator find(const key_type& x);
|
| 3085 |
const_iterator find(const key_type& x) const;
|
| 3086 |
+
template <class K> iterator find(const K& x);
|
| 3087 |
+
template <class K> const_iterator find(const K& x) const;
|
| 3088 |
+
|
| 3089 |
size_type count(const key_type& x) const;
|
| 3090 |
+
template <class K> size_type count(const K& x) const;
|
| 3091 |
|
| 3092 |
iterator lower_bound(const key_type& x);
|
| 3093 |
const_iterator lower_bound(const key_type& x) const;
|
| 3094 |
+
template <class K> iterator lower_bound(const K& x);
|
| 3095 |
+
template <class K> const_iterator lower_bound(const K& x) const;
|
| 3096 |
+
|
| 3097 |
iterator upper_bound(const key_type& x);
|
| 3098 |
const_iterator upper_bound(const key_type& x) const;
|
| 3099 |
+
template <class K> iterator upper_bound(const K& x);
|
| 3100 |
+
template <class K> const_iterator upper_bound(const K& x) const;
|
| 3101 |
|
| 3102 |
pair<iterator,iterator>
|
| 3103 |
equal_range(const key_type& x);
|
| 3104 |
pair<const_iterator,const_iterator>
|
| 3105 |
equal_range(const key_type& x) const;
|
| 3106 |
+
template <class K>
|
| 3107 |
+
pair<iterator, iterator> equal_range(const K& x);
|
| 3108 |
+
template <class K>
|
| 3109 |
+
pair<const_iterator, const_iterator> equal_range(const K& x) const;
|
| 3110 |
};
|
| 3111 |
|
| 3112 |
template <class Key, class T, class Compare, class Allocator>
|
| 3113 |
bool operator==(const map<Key,T,Compare,Allocator>& x,
|
| 3114 |
const map<Key,T,Compare,Allocator>& y);
|
|
|
|
| 3136 |
```
|
| 3137 |
|
| 3138 |
#### `map` constructors, copy, and assignment <a id="map.cons">[[map.cons]]</a>
|
| 3139 |
|
| 3140 |
``` cpp
|
| 3141 |
+
explicit map(const Compare& comp,
|
| 3142 |
const Allocator& = Allocator());
|
| 3143 |
```
|
| 3144 |
|
| 3145 |
*Effects:* Constructs an empty `map` using the specified comparison
|
| 3146 |
object and allocator.
|
|
|
|
| 3151 |
template <class InputIterator>
|
| 3152 |
map(InputIterator first, InputIterator last,
|
| 3153 |
const Compare& comp = Compare(), const Allocator& = Allocator());
|
| 3154 |
```
|
| 3155 |
|
| 3156 |
+
*Requires:* If the iterator’s indirection operator returns an lvalue or
|
| 3157 |
a const rvalue `pair<key_type, mapped_type>`, then both `key_type` and
|
| 3158 |
+
`mapped_type` shall be `CopyInsertable` into `*this`.
|
| 3159 |
|
| 3160 |
*Effects:* Constructs an empty `map` using the specified comparison
|
| 3161 |
object and allocator, and inserts elements from the range \[`first`,
|
| 3162 |
`last`).
|
| 3163 |
|
|
|
|
| 3171 |
```
|
| 3172 |
|
| 3173 |
*Effects:* If there is no key equivalent to `x` in the map, inserts
|
| 3174 |
`value_type(x, T())` into the map.
|
| 3175 |
|
| 3176 |
+
*Requires:* `key_type` shall be `CopyInsertable` and `mapped_type` shall
|
| 3177 |
+
be `DefaultInsertable` into `*this`.
|
| 3178 |
|
| 3179 |
*Returns:* A reference to the `mapped_type` corresponding to `x` in
|
| 3180 |
`*this`.
|
| 3181 |
|
| 3182 |
+
*Complexity:* Logarithmic.
|
| 3183 |
|
| 3184 |
``` cpp
|
| 3185 |
T& operator[](key_type&& x);
|
| 3186 |
```
|
| 3187 |
|
| 3188 |
*Effects:* If there is no key equivalent to `x` in the map, inserts
|
| 3189 |
`value_type(std::move(x), T())` into the map.
|
| 3190 |
|
| 3191 |
+
*Requires:* `mapped_type` shall be `DefaultInsertable` into `*this`.
|
| 3192 |
|
| 3193 |
*Returns:* A reference to the `mapped_type` corresponding to `x` in
|
| 3194 |
`*this`.
|
| 3195 |
|
| 3196 |
+
*Complexity:* Logarithmic.
|
| 3197 |
|
| 3198 |
``` cpp
|
| 3199 |
T& at(const key_type& x);
|
| 3200 |
const T& at(const key_type& x) const;
|
| 3201 |
```
|
|
|
|
| 3204 |
`*this`.
|
| 3205 |
|
| 3206 |
*Throws:* An exception object of type `out_of_range` if no such element
|
| 3207 |
is present.
|
| 3208 |
|
| 3209 |
+
*Complexity:* Logarithmic.
|
| 3210 |
|
| 3211 |
#### `map` modifiers <a id="map.modifiers">[[map.modifiers]]</a>
|
| 3212 |
|
| 3213 |
``` cpp
|
| 3214 |
template <class P> pair<iterator, bool> insert(P&& x);
|
| 3215 |
+
template <class P> iterator insert(const_iterator position, P&& x);
|
| 3216 |
template <class InputIterator>
|
| 3217 |
void insert(InputIterator first, InputIterator last);
|
| 3218 |
```
|
| 3219 |
|
| 3220 |
+
*Effects:* The first form is equivalent to
|
| 3221 |
+
`return emplace(std::forward<P>(x))`. The second form is equivalent to
|
| 3222 |
+
`return emplace_hint(position, std::forward<P>(x))`.
|
| 3223 |
|
| 3224 |
+
*Remarks:* These signatures shall not participate in overload resolution
|
| 3225 |
+
unless `std::is_constructible<value_type, P&&>::value` is `true`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3226 |
|
| 3227 |
#### `map` specialized algorithms <a id="map.special">[[map.special]]</a>
|
| 3228 |
|
| 3229 |
``` cpp
|
| 3230 |
template <class Key, class T, class Compare, class Allocator>
|
|
|
|
| 3295 |
return comp(x.first, y.first);
|
| 3296 |
}
|
| 3297 |
};
|
| 3298 |
|
| 3299 |
// construct/copy/destroy:
|
| 3300 |
+
multimap() : multimap(Compare()) { }
|
| 3301 |
+
explicit multimap(const Compare& comp,
|
| 3302 |
const Allocator& = Allocator());
|
| 3303 |
template <class InputIterator>
|
| 3304 |
multimap(InputIterator first, InputIterator last,
|
| 3305 |
const Compare& comp = Compare(),
|
| 3306 |
const Allocator& = Allocator());
|
| 3307 |
+
multimap(const multimap& x);
|
| 3308 |
+
multimap(multimap&& x);
|
| 3309 |
explicit multimap(const Allocator&);
|
| 3310 |
multimap(const multimap&, const Allocator&);
|
| 3311 |
multimap(multimap&&, const Allocator&);
|
| 3312 |
multimap(initializer_list<value_type>,
|
| 3313 |
const Compare& = Compare(),
|
| 3314 |
const Allocator& = Allocator());
|
| 3315 |
+
template <class InputIterator>
|
| 3316 |
+
multimap(InputIterator first, InputIterator last, const Allocator& a)
|
| 3317 |
+
: multimap(first, last, Compare(), a) { }
|
| 3318 |
+
multimap(initializer_list<value_type> il, const Allocator& a)
|
| 3319 |
+
: multimap(il, Compare(), a) { }
|
| 3320 |
~multimap();
|
| 3321 |
+
multimap& operator=(const multimap& x);
|
| 3322 |
+
multimap& operator=(multimap&& x);
|
|
|
|
|
|
|
| 3323 |
multimap& operator=(initializer_list<value_type>);
|
| 3324 |
allocator_type get_allocator() const noexcept;
|
| 3325 |
|
| 3326 |
// iterators:
|
| 3327 |
iterator begin() noexcept;
|
|
|
|
| 3356 |
void insert(initializer_list<value_type>);
|
| 3357 |
|
| 3358 |
iterator erase(const_iterator position);
|
| 3359 |
size_type erase(const key_type& x);
|
| 3360 |
iterator erase(const_iterator first, const_iterator last);
|
| 3361 |
+
void swap(multimap&);
|
| 3362 |
void clear() noexcept;
|
| 3363 |
|
| 3364 |
// observers:
|
| 3365 |
key_compare key_comp() const;
|
| 3366 |
value_compare value_comp() const;
|
| 3367 |
|
| 3368 |
// map operations:
|
| 3369 |
iterator find(const key_type& x);
|
| 3370 |
const_iterator find(const key_type& x) const;
|
| 3371 |
+
template <class K> iterator find(const K& x);
|
| 3372 |
+
template <class K> const_iterator find(const K& x) const;
|
| 3373 |
+
|
| 3374 |
size_type count(const key_type& x) const;
|
| 3375 |
+
template <class K> size_type count(const K& x) const;
|
| 3376 |
|
| 3377 |
iterator lower_bound(const key_type& x);
|
| 3378 |
const_iterator lower_bound(const key_type& x) const;
|
| 3379 |
+
template <class K> iterator lower_bound(const K& x);
|
| 3380 |
+
template <class K> const_iterator lower_bound(const K& x) const;
|
| 3381 |
+
|
| 3382 |
iterator upper_bound(const key_type& x);
|
| 3383 |
const_iterator upper_bound(const key_type& x) const;
|
| 3384 |
+
template <class K> iterator upper_bound(const K& x);
|
| 3385 |
+
template <class K> const_iterator upper_bound(const K& x) const;
|
| 3386 |
|
| 3387 |
pair<iterator,iterator>
|
| 3388 |
equal_range(const key_type& x);
|
| 3389 |
pair<const_iterator,const_iterator>
|
| 3390 |
equal_range(const key_type& x) const;
|
| 3391 |
+
template <class K>
|
| 3392 |
+
pair<iterator, iterator> equal_range(const K& x);
|
| 3393 |
+
template <class K>
|
| 3394 |
+
pair<const_iterator, const_iterator> equal_range(const K& x) const;
|
| 3395 |
};
|
| 3396 |
|
| 3397 |
template <class Key, class T, class Compare, class Allocator>
|
| 3398 |
bool operator==(const multimap<Key,T,Compare,Allocator>& x,
|
| 3399 |
const multimap<Key,T,Compare,Allocator>& y);
|
|
|
|
| 3421 |
```
|
| 3422 |
|
| 3423 |
#### `multimap` constructors <a id="multimap.cons">[[multimap.cons]]</a>
|
| 3424 |
|
| 3425 |
``` cpp
|
| 3426 |
+
explicit multimap(const Compare& comp,
|
| 3427 |
const Allocator& = Allocator());
|
| 3428 |
```
|
| 3429 |
|
| 3430 |
*Effects:* Constructs an empty `multimap` using the specified comparison
|
| 3431 |
object and allocator.
|
|
|
|
| 3437 |
multimap(InputIterator first, InputIterator last,
|
| 3438 |
const Compare& comp = Compare(),
|
| 3439 |
const Allocator& = Allocator());
|
| 3440 |
```
|
| 3441 |
|
| 3442 |
+
*Requires:* If the iterator’s indirection operator returns an lvalue or
|
| 3443 |
a const rvalue `pair<key_type, mapped_type>`, then both `key_type` and
|
| 3444 |
+
`mapped_type` shall be `CopyInsertable` into `*this`.
|
| 3445 |
|
| 3446 |
*Effects:* Constructs an empty `multimap` using the specified comparison
|
| 3447 |
object and allocator, and inserts elements from the range \[`first`,
|
| 3448 |
`last`).
|
| 3449 |
|
|
|
|
| 3455 |
``` cpp
|
| 3456 |
template <class P> iterator insert(P&& x);
|
| 3457 |
template <class P> iterator insert(const_iterator position, P&& x);
|
| 3458 |
```
|
| 3459 |
|
| 3460 |
+
*Effects:* The first form is equivalent to
|
| 3461 |
+
`return emplace(std::forward<P>(x))`. The second form is equivalent to
|
| 3462 |
+
`return emplace_hint(position, std::forward<P>(x))`.
|
| 3463 |
|
| 3464 |
+
*Remarks:* These signatures shall not participate in overload resolution
|
| 3465 |
+
unless `std::is_constructible<value_type, P&&>::value` is `true`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3466 |
|
| 3467 |
#### `multimap` specialized algorithms <a id="multimap.special">[[multimap.special]]</a>
|
| 3468 |
|
| 3469 |
``` cpp
|
| 3470 |
template <class Key, class T, class Compare, class Allocator>
|
|
|
|
| 3520 |
typedef typename allocator_traits<Allocator>::const_pointer const_pointer;
|
| 3521 |
typedef std::reverse_iterator<iterator> reverse_iterator;
|
| 3522 |
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
| 3523 |
|
| 3524 |
// [set.cons], construct/copy/destroy:
|
| 3525 |
+
set() : set(Compare()) { }
|
| 3526 |
+
explicit set(const Compare& comp,
|
| 3527 |
const Allocator& = Allocator());
|
| 3528 |
template <class InputIterator>
|
| 3529 |
set(InputIterator first, InputIterator last,
|
| 3530 |
const Compare& comp = Compare(), const Allocator& = Allocator());
|
| 3531 |
+
set(const set& x);
|
| 3532 |
+
set(set&& x);
|
| 3533 |
explicit set(const Allocator&);
|
| 3534 |
set(const set&, const Allocator&);
|
| 3535 |
set(set&&, const Allocator&);
|
| 3536 |
set(initializer_list<value_type>,
|
| 3537 |
const Compare& = Compare(),
|
| 3538 |
const Allocator& = Allocator());
|
| 3539 |
+
template <class InputIterator>
|
| 3540 |
+
set(InputIterator first, InputIterator last, const Allocator& a)
|
| 3541 |
+
: set(first, last, Compare(), a) { }
|
| 3542 |
+
set(initializer_list<value_type> il, const Allocator& a)
|
| 3543 |
+
: set(il, Compare(), a) { }
|
| 3544 |
~set();
|
| 3545 |
+
set& operator=(const set& x);
|
| 3546 |
+
set& operator=(set&& x);
|
|
|
|
|
|
|
| 3547 |
set& operator=(initializer_list<value_type>);
|
| 3548 |
allocator_type get_allocator() const noexcept;
|
| 3549 |
|
| 3550 |
// iterators:
|
| 3551 |
iterator begin() noexcept;
|
|
|
|
| 3580 |
void insert(initializer_list<value_type>);
|
| 3581 |
|
| 3582 |
iterator erase(const_iterator position);
|
| 3583 |
size_type erase(const key_type& x);
|
| 3584 |
iterator erase(const_iterator first, const_iterator last);
|
| 3585 |
+
void swap(set&);
|
| 3586 |
void clear() noexcept;
|
| 3587 |
|
| 3588 |
// observers:
|
| 3589 |
key_compare key_comp() const;
|
| 3590 |
value_compare value_comp() const;
|
| 3591 |
|
| 3592 |
// set operations:
|
| 3593 |
iterator find(const key_type& x);
|
| 3594 |
const_iterator find(const key_type& x) const;
|
| 3595 |
+
template <class K> iterator find(const K& x);
|
| 3596 |
+
template <class K> const_iterator find(const K& x) const;
|
| 3597 |
|
| 3598 |
size_type count(const key_type& x) const;
|
| 3599 |
+
template <class K> size_type count(const K& x) const;
|
| 3600 |
|
| 3601 |
iterator lower_bound(const key_type& x);
|
| 3602 |
const_iterator lower_bound(const key_type& x) const;
|
| 3603 |
+
template <class K> iterator lower_bound(const K& x);
|
| 3604 |
+
template <class K> const_iterator lower_bound(const K& x) const;
|
| 3605 |
|
| 3606 |
iterator upper_bound(const key_type& x);
|
| 3607 |
const_iterator upper_bound(const key_type& x) const;
|
| 3608 |
+
template <class K> iterator upper_bound(const K& x);
|
| 3609 |
+
template <class K> const_iterator upper_bound(const K& x) const;
|
| 3610 |
|
| 3611 |
pair<iterator,iterator> equal_range(const key_type& x);
|
| 3612 |
pair<const_iterator,const_iterator> equal_range(const key_type& x) const;
|
| 3613 |
+
template <class K>
|
| 3614 |
+
pair<iterator, iterator> equal_range(const K& x);
|
| 3615 |
+
template <class K>
|
| 3616 |
+
pair<const_iterator, const_iterator> equal_range(const K& x) const;
|
| 3617 |
};
|
| 3618 |
|
| 3619 |
template <class Key, class Compare, class Allocator>
|
| 3620 |
bool operator==(const set<Key,Compare,Allocator>& x,
|
| 3621 |
const set<Key,Compare,Allocator>& y);
|
|
|
|
| 3643 |
```
|
| 3644 |
|
| 3645 |
#### `set` constructors, copy, and assignment <a id="set.cons">[[set.cons]]</a>
|
| 3646 |
|
| 3647 |
``` cpp
|
| 3648 |
+
explicit set(const Compare& comp,
|
| 3649 |
const Allocator& = Allocator());
|
| 3650 |
```
|
| 3651 |
|
| 3652 |
*Effects:* Constructs an empty set using the specified comparison
|
| 3653 |
objects and allocator.
|
|
|
|
| 3662 |
|
| 3663 |
*Effects:* Constructs an empty `set` using the specified comparison
|
| 3664 |
object and allocator, and inserts elements from the range \[`first`,
|
| 3665 |
`last`).
|
| 3666 |
|
| 3667 |
+
*Requires:* If the iterator’s indirection operator returns an lvalue or
|
| 3668 |
+
a non-const rvalue, then `Key` shall be `CopyInsertable` into `*this`.
|
| 3669 |
|
| 3670 |
*Complexity:* Linear in N if the range \[`first`, `last`) is already
|
| 3671 |
sorted using `comp` and otherwise N log N, where N is `last - first`.
|
| 3672 |
|
| 3673 |
#### `set` specialized algorithms <a id="set.special">[[set.special]]</a>
|
|
|
|
| 3727 |
typedef typename allocator_traits<Allocator>::const_pointer const_pointer;
|
| 3728 |
typedef std::reverse_iterator<iterator> reverse_iterator;
|
| 3729 |
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
| 3730 |
|
| 3731 |
// construct/copy/destroy:
|
| 3732 |
+
multiset() : multiset(Compare()) { }
|
| 3733 |
+
explicit multiset(const Compare& comp,
|
| 3734 |
const Allocator& = Allocator());
|
| 3735 |
template <class InputIterator>
|
| 3736 |
multiset(InputIterator first, InputIterator last,
|
| 3737 |
const Compare& comp = Compare(),
|
| 3738 |
const Allocator& = Allocator());
|
| 3739 |
+
multiset(const multiset& x);
|
| 3740 |
+
multiset(multiset&& x);
|
| 3741 |
explicit multiset(const Allocator&);
|
| 3742 |
multiset(const multiset&, const Allocator&);
|
| 3743 |
multiset(multiset&&, const Allocator&);
|
| 3744 |
multiset(initializer_list<value_type>,
|
| 3745 |
const Compare& = Compare(),
|
| 3746 |
const Allocator& = Allocator());
|
| 3747 |
+
template <class InputIterator>
|
| 3748 |
+
multiset(InputIterator first, InputIterator last, const Allocator& a)
|
| 3749 |
+
: multiset(first, last, Compare(), a) { }
|
| 3750 |
+
multiset(initializer_list<value_type> il, const Allocator& a)
|
| 3751 |
+
: multiset(il, Compare(), a) { }
|
| 3752 |
~multiset();
|
| 3753 |
+
multiset& operator=(const multiset& x);
|
| 3754 |
+
multiset& operator=(multiset&& x);
|
|
|
|
|
|
|
| 3755 |
multiset& operator=(initializer_list<value_type>);
|
| 3756 |
allocator_type get_allocator() const noexcept;
|
| 3757 |
|
| 3758 |
// iterators:
|
| 3759 |
iterator begin() noexcept;
|
|
|
|
| 3788 |
void insert(initializer_list<value_type>);
|
| 3789 |
|
| 3790 |
iterator erase(const_iterator position);
|
| 3791 |
size_type erase(const key_type& x);
|
| 3792 |
iterator erase(const_iterator first, const_iterator last);
|
| 3793 |
+
void swap(multiset&);
|
| 3794 |
void clear() noexcept;
|
| 3795 |
|
| 3796 |
// observers:
|
| 3797 |
key_compare key_comp() const;
|
| 3798 |
value_compare value_comp() const;
|
| 3799 |
|
| 3800 |
// set operations:
|
| 3801 |
iterator find(const key_type& x);
|
| 3802 |
const_iterator find(const key_type& x) const;
|
| 3803 |
+
template <class K> iterator find(const K& x);
|
| 3804 |
+
template <class K> const_iterator find(const K& x) const;
|
| 3805 |
|
| 3806 |
size_type count(const key_type& x) const;
|
| 3807 |
+
template <class K> size_type count(const K& x) const;
|
| 3808 |
|
| 3809 |
iterator lower_bound(const key_type& x);
|
| 3810 |
const_iterator lower_bound(const key_type& x) const;
|
| 3811 |
+
template <class K> iterator lower_bound(const K& x);
|
| 3812 |
+
template <class K> const_iterator lower_bound(const K& x) const;
|
| 3813 |
|
| 3814 |
iterator upper_bound(const key_type& x);
|
| 3815 |
const_iterator upper_bound(const key_type& x) const;
|
| 3816 |
+
template <class K> iterator upper_bound(const K& x);
|
| 3817 |
+
template <class K> const_iterator upper_bound(const K& x) const;
|
| 3818 |
|
| 3819 |
pair<iterator,iterator> equal_range(const key_type& x);
|
| 3820 |
pair<const_iterator,const_iterator> equal_range(const key_type& x) const;
|
| 3821 |
+
template <class K>
|
| 3822 |
+
pair<iterator, iterator> equal_range(const K& x);
|
| 3823 |
+
template <class K>
|
| 3824 |
+
pair<const_iterator, const_iterator> equal_range(const K& x) const;
|
| 3825 |
};
|
| 3826 |
|
| 3827 |
template <class Key, class Compare, class Allocator>
|
| 3828 |
bool operator==(const multiset<Key,Compare,Allocator>& x,
|
| 3829 |
const multiset<Key,Compare,Allocator>& y);
|
|
|
|
| 3851 |
```
|
| 3852 |
|
| 3853 |
#### `multiset` constructors <a id="multiset.cons">[[multiset.cons]]</a>
|
| 3854 |
|
| 3855 |
``` cpp
|
| 3856 |
+
explicit multiset(const Compare& comp,
|
| 3857 |
const Allocator& = Allocator());
|
| 3858 |
```
|
| 3859 |
|
| 3860 |
*Effects:* Constructs an empty set using the specified comparison object
|
| 3861 |
and allocator.
|
| 3862 |
|
| 3863 |
*Complexity:* Constant.
|
| 3864 |
|
| 3865 |
``` cpp
|
| 3866 |
template <class InputIterator>
|
| 3867 |
+
multiset(InputIterator first, InputIterator last,
|
| 3868 |
const Compare& comp = Compare(), const Allocator& = Allocator());
|
| 3869 |
```
|
| 3870 |
|
| 3871 |
+
*Requires:* If the iterator’s indirection operator returns an lvalue or
|
| 3872 |
+
a const rvalue, then `Key` shall be `CopyInsertable` into `*this`.
|
| 3873 |
|
| 3874 |
*Effects:* Constructs an empty `multiset` using the specified comparison
|
| 3875 |
object and allocator, and inserts elements from the range \[`first`,
|
| 3876 |
`last`).
|
| 3877 |
|
|
|
|
| 4027 |
typedef std::pair<const Key, T> value_type;
|
| 4028 |
typedef T mapped_type;
|
| 4029 |
typedef Hash hasher;
|
| 4030 |
typedef Pred key_equal;
|
| 4031 |
typedef Allocator allocator_type;
|
| 4032 |
+
typedef typename allocator_traits<Allocator>::pointer pointer;
|
| 4033 |
+
typedef typename allocator_traits<Allocator>::const_pointer const_pointer;
|
| 4034 |
+
typedef value_type& reference;
|
| 4035 |
+
typedef const value_type& const_reference;
|
| 4036 |
typedef implementation-defined size_type;
|
| 4037 |
typedef implementation-defined difference_type;
|
| 4038 |
|
| 4039 |
typedef implementation-defined iterator;
|
| 4040 |
typedef implementation-defined const_iterator;
|
| 4041 |
typedef implementation-defined local_iterator;
|
| 4042 |
typedef implementation-defined const_local_iterator;
|
| 4043 |
|
| 4044 |
// construct/destroy/copy
|
| 4045 |
+
unordered_map();
|
| 4046 |
+
explicit unordered_map(size_type n,
|
| 4047 |
const hasher& hf = hasher(),
|
| 4048 |
const key_equal& eql = key_equal(),
|
| 4049 |
const allocator_type& a = allocator_type());
|
| 4050 |
template <class InputIterator>
|
| 4051 |
unordered_map(InputIterator f, InputIterator l,
|
|
|
|
| 4061 |
unordered_map(initializer_list<value_type>,
|
| 4062 |
size_type = see below,
|
| 4063 |
const hasher& hf = hasher(),
|
| 4064 |
const key_equal& eql = key_equal(),
|
| 4065 |
const allocator_type& a = allocator_type());
|
| 4066 |
+
unordered_map(size_type n, const allocator_type& a)
|
| 4067 |
+
: unordered_map(n, hasher(), key_equal(), a) { }
|
| 4068 |
+
unordered_map(size_type n, const hasher& hf, const allocator_type& a)
|
| 4069 |
+
: unordered_map(n, hf, key_equal(), a) { }
|
| 4070 |
+
template <class InputIterator>
|
| 4071 |
+
unordered_map(InputIterator f, InputIterator l, size_type n, const allocator_type& a)
|
| 4072 |
+
: unordered_map(f, l, n, hasher(), key_equal(), a) { }
|
| 4073 |
+
template <class InputIterator>
|
| 4074 |
+
unordered_map(InputIterator f, InputIterator l, size_type n, const hasher& hf,
|
| 4075 |
+
const allocator_type& a)
|
| 4076 |
+
: unordered_map(f, l, n, hf, key_equal(), a) { }
|
| 4077 |
+
unordered_map(initializer_list<value_type> il, size_type n, const allocator_type& a)
|
| 4078 |
+
: unordered_map(il, n, hasher(), key_equal(), a) { }
|
| 4079 |
+
unordered_map(initializer_list<value_type> il, size_type n, const hasher& hf,
|
| 4080 |
+
const allocator_type& a)
|
| 4081 |
+
: unordered_map(il, n, hf, key_equal(), a) { }
|
| 4082 |
~unordered_map();
|
| 4083 |
unordered_map& operator=(const unordered_map&);
|
| 4084 |
unordered_map& operator=(unordered_map&&);
|
| 4085 |
unordered_map& operator=(initializer_list<value_type>);
|
| 4086 |
allocator_type get_allocator() const noexcept;
|
|
|
|
| 4165 |
```
|
| 4166 |
|
| 4167 |
#### `unordered_map` constructors <a id="unord.map.cnstr">[[unord.map.cnstr]]</a>
|
| 4168 |
|
| 4169 |
``` cpp
|
| 4170 |
+
unordered_map() : unordered_map(size_type(see below)) { }
|
| 4171 |
+
explicit unordered_map(size_type n,
|
| 4172 |
const hasher& hf = hasher(),
|
| 4173 |
const key_equal& eql = key_equal(),
|
| 4174 |
const allocator_type& a = allocator_type());
|
| 4175 |
```
|
| 4176 |
|
| 4177 |
*Effects:* Constructs an empty `unordered_map` using the specified hash
|
| 4178 |
function, key equality function, and allocator, and using at least *`n`*
|
| 4179 |
+
buckets. For the default constructor, the number of buckets is
|
| 4180 |
*implementation-defined*. `max_load_factor()` returns 1.0.
|
| 4181 |
|
| 4182 |
*Complexity:* Constant.
|
| 4183 |
|
| 4184 |
``` cpp
|
|
|
|
| 4203 |
``` cpp
|
| 4204 |
mapped_type& operator[](const key_type& k);
|
| 4205 |
mapped_type& operator[](key_type&& k);
|
| 4206 |
```
|
| 4207 |
|
| 4208 |
+
*Requires:* `mapped_type` shall be `DefaultInsertable` into `*this`. For
|
| 4209 |
+
the first operator, `key_type` shall be `CopyInsertable` into `*this`.
|
| 4210 |
+
For the second operator, `key_type` shall be `MoveConstructible`.
|
| 4211 |
|
| 4212 |
*Effects:* If the `unordered_map` does not already contain an element
|
| 4213 |
whose key is equivalent to *`k`*, the first operator inserts the value
|
| 4214 |
`value_type(k, mapped_type())` and the second operator inserts the value
|
| 4215 |
`value_type(std::move(k), mapped_type())`.
|
|
|
|
| 4235 |
``` cpp
|
| 4236 |
template <class P>
|
| 4237 |
pair<iterator, bool> insert(P&& obj);
|
| 4238 |
```
|
| 4239 |
|
| 4240 |
+
*Effects:* Equivalent to `return emplace(std::forward<P>(obj))`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4241 |
|
| 4242 |
*Remarks:* This signature shall not participate in overload resolution
|
| 4243 |
+
unless `std::is_constructible<value_type, P&&>::value` is `true`.
|
| 4244 |
|
| 4245 |
``` cpp
|
| 4246 |
template <class P>
|
| 4247 |
iterator insert(const_iterator hint, P&& obj);
|
| 4248 |
```
|
| 4249 |
|
| 4250 |
+
*Effects:* Equivalent to
|
| 4251 |
+
`return emplace_hint(hint, std::forward<P>(obj))`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4252 |
|
| 4253 |
*Remarks:* This signature shall not participate in overload resolution
|
| 4254 |
+
unless `std::is_constructible<value_type, P&&>::value` is `true`.
|
| 4255 |
|
| 4256 |
#### `unordered_map` swap <a id="unord.map.swap">[[unord.map.swap]]</a>
|
| 4257 |
|
| 4258 |
``` cpp
|
| 4259 |
template <class Key, class T, class Hash, class Pred, class Alloc>
|
|
|
|
| 4301 |
typedef std::pair<const Key, T> value_type;
|
| 4302 |
typedef T mapped_type;
|
| 4303 |
typedef Hash hasher;
|
| 4304 |
typedef Pred key_equal;
|
| 4305 |
typedef Allocator allocator_type;
|
| 4306 |
+
typedef typename allocator_traits<Allocator>::pointer pointer;
|
| 4307 |
+
typedef typename allocator_traits<Allocator>::const_pointer const_pointer;
|
| 4308 |
+
typedef value_type& reference;
|
| 4309 |
+
typedef const value_type& const_reference;
|
| 4310 |
typedef implementation-defined size_type;
|
| 4311 |
typedef implementation-defined difference_type;
|
| 4312 |
|
| 4313 |
typedef implementation-defined iterator;
|
| 4314 |
typedef implementation-defined const_iterator;
|
| 4315 |
typedef implementation-defined local_iterator;
|
| 4316 |
typedef implementation-defined const_local_iterator;
|
| 4317 |
|
| 4318 |
// construct/destroy/copy
|
| 4319 |
+
unordered_multimap();
|
| 4320 |
+
explicit unordered_multimap(size_type n,
|
| 4321 |
const hasher& hf = hasher(),
|
| 4322 |
const key_equal& eql = key_equal(),
|
| 4323 |
const allocator_type& a = allocator_type());
|
| 4324 |
template <class InputIterator>
|
| 4325 |
unordered_multimap(InputIterator f, InputIterator l,
|
|
|
|
| 4335 |
unordered_multimap(initializer_list<value_type>,
|
| 4336 |
size_type = see below,
|
| 4337 |
const hasher& hf = hasher(),
|
| 4338 |
const key_equal& eql = key_equal(),
|
| 4339 |
const allocator_type& a = allocator_type());
|
| 4340 |
+
unordered_multimap(size_type n, const allocator_type& a)
|
| 4341 |
+
: unordered_multimap(n, hasher(), key_equal(), a) { }
|
| 4342 |
+
unordered_multimap(size_type n, const hasher& hf, const allocator_type& a)
|
| 4343 |
+
: unordered_multimap(n, hf, key_equal(), a) { }
|
| 4344 |
+
template <class InputIterator>
|
| 4345 |
+
unordered_multimap(InputIterator f, InputIterator l, size_type n, const allocator_type& a)
|
| 4346 |
+
: unordered_multimap(f, l, n, hasher(), key_equal(), a) { }
|
| 4347 |
+
template <class InputIterator>
|
| 4348 |
+
unordered_multimap(InputIterator f, InputIterator l, size_type n, const hasher& hf,
|
| 4349 |
+
const allocator_type& a)
|
| 4350 |
+
: unordered_multimap(f, l, n, hf, key_equal(), a) { }
|
| 4351 |
+
unordered_multimap(initializer_list<value_type> il, size_type n, const allocator_type& a)
|
| 4352 |
+
: unordered_multimap(il, n, hasher(), key_equal(), a) { }
|
| 4353 |
+
unordered_multimap(initializer_list<value_type> il, size_type n, const hasher& hf,
|
| 4354 |
+
const allocator_type& a)
|
| 4355 |
+
: unordered_multimap(il, n, hf, key_equal(), a) { }
|
| 4356 |
~unordered_multimap();
|
| 4357 |
unordered_multimap& operator=(const unordered_multimap&);
|
| 4358 |
unordered_multimap& operator=(unordered_multimap&&);
|
| 4359 |
unordered_multimap& operator=(initializer_list<value_type>);
|
| 4360 |
allocator_type get_allocator() const noexcept;
|
|
|
|
| 4434 |
```
|
| 4435 |
|
| 4436 |
#### `unordered_multimap` constructors <a id="unord.multimap.cnstr">[[unord.multimap.cnstr]]</a>
|
| 4437 |
|
| 4438 |
``` cpp
|
| 4439 |
+
unordered_multimap() : unordered_multimap(size_type(see below)) { }
|
| 4440 |
+
explicit unordered_multimap(size_type n,
|
| 4441 |
const hasher& hf = hasher(),
|
| 4442 |
const key_equal& eql = key_equal(),
|
| 4443 |
const allocator_type& a = allocator_type());
|
| 4444 |
```
|
| 4445 |
|
| 4446 |
*Effects:* Constructs an empty `unordered_multimap` using the specified
|
| 4447 |
hash function, key equality function, and allocator, and using at least
|
| 4448 |
+
*`n`* buckets. For the default constructor, the number of buckets is
|
| 4449 |
*implementation-defined*. `max_load_factor()` returns 1.0.
|
| 4450 |
|
| 4451 |
*Complexity:* Constant.
|
| 4452 |
|
| 4453 |
``` cpp
|
|
|
|
| 4472 |
``` cpp
|
| 4473 |
template <class P>
|
| 4474 |
iterator insert(P&& obj);
|
| 4475 |
```
|
| 4476 |
|
| 4477 |
+
*Effects:* Equivalent to `return emplace(std::forward<P>(obj))`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4478 |
|
| 4479 |
*Remarks:* This signature shall not participate in overload resolution
|
| 4480 |
+
unless `std::is_constructible<value_type, P&&>::value` is `true`.
|
| 4481 |
|
| 4482 |
``` cpp
|
| 4483 |
template <class P>
|
| 4484 |
iterator insert(const_iterator hint, P&& obj);
|
| 4485 |
```
|
| 4486 |
|
| 4487 |
+
*Effects:* Equivalent to
|
| 4488 |
+
`return emplace_hint(hint, std::forward<P>(obj))`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4489 |
|
| 4490 |
*Remarks:* This signature shall not participate in overload resolution
|
| 4491 |
+
unless `std::is_constructible<value_type, P&&>::value` is `true`.
|
| 4492 |
|
| 4493 |
#### `unordered_multimap` swap <a id="unord.multimap.swap">[[unord.multimap.swap]]</a>
|
| 4494 |
|
| 4495 |
``` cpp
|
| 4496 |
template <class Key, class T, class Hash, class Pred, class Alloc>
|
|
|
|
| 4536 |
typedef Key key_type;
|
| 4537 |
typedef Key value_type;
|
| 4538 |
typedef Hash hasher;
|
| 4539 |
typedef Pred key_equal;
|
| 4540 |
typedef Allocator allocator_type;
|
| 4541 |
+
typedef typename allocator_traits<Allocator>::pointer pointer;
|
| 4542 |
+
typedef typename allocator_traits<Allocator>::const_pointer const_pointer;
|
| 4543 |
+
typedef value_type& reference;
|
| 4544 |
+
typedef const value_type& const_reference;
|
| 4545 |
typedef implementation-defined size_type;
|
| 4546 |
typedef implementation-defined difference_type;
|
| 4547 |
|
| 4548 |
typedef implementation-defined iterator;
|
| 4549 |
typedef implementation-defined const_iterator;
|
| 4550 |
typedef implementation-defined local_iterator;
|
| 4551 |
typedef implementation-defined const_local_iterator;
|
| 4552 |
|
| 4553 |
// construct/destroy/copy
|
| 4554 |
+
unordered_set();
|
| 4555 |
+
explicit unordered_set(size_type n,
|
| 4556 |
const hasher& hf = hasher(),
|
| 4557 |
const key_equal& eql = key_equal(),
|
| 4558 |
const allocator_type& a = allocator_type());
|
| 4559 |
template <class InputIterator>
|
| 4560 |
unordered_set(InputIterator f, InputIterator l,
|
|
|
|
| 4570 |
unordered_set(initializer_list<value_type>,
|
| 4571 |
size_type = see below,
|
| 4572 |
const hasher& hf = hasher(),
|
| 4573 |
const key_equal& eql = key_equal(),
|
| 4574 |
const allocator_type& a = allocator_type());
|
| 4575 |
+
unordered_set(size_type n, const allocator_type& a)
|
| 4576 |
+
: unordered_set(n, hasher(), key_equal(), a) { }
|
| 4577 |
+
unordered_set(size_type n, const hasher& hf, const allocator_type& a)
|
| 4578 |
+
: unordered_set(n, hf, key_equal(), a) { }
|
| 4579 |
+
template <class InputIterator>
|
| 4580 |
+
unordered_set(InputIterator f, InputIterator l, size_type n, const allocator_type& a)
|
| 4581 |
+
: unordered_set(f, l, n, hasher(), key_equal(), a) { }
|
| 4582 |
+
template <class InputIterator>
|
| 4583 |
+
unordered_set(InputIterator f, InputIterator l, size_type n, const hasher& hf,
|
| 4584 |
+
const allocator_type& a)
|
| 4585 |
+
: unordered_set(f, l, n, hf, key_equal(), a) { }
|
| 4586 |
+
unordered_set(initializer_list<value_type> il, size_type n, const allocator_type& a)
|
| 4587 |
+
: unordered_set(il, n, hasher(), key_equal(), a) { }
|
| 4588 |
+
unordered_set(initializer_list<value_type> il, size_type n, const hasher& hf,
|
| 4589 |
+
const allocator_type& a)
|
| 4590 |
+
: unordered_set(il, n, hf, key_equal(), a) { }
|
| 4591 |
~unordered_set();
|
| 4592 |
unordered_set& operator=(const unordered_set&);
|
| 4593 |
unordered_set& operator=(unordered_set&&);
|
| 4594 |
unordered_set& operator=(initializer_list<value_type>);
|
| 4595 |
allocator_type get_allocator() const noexcept;
|
|
|
|
| 4657 |
|
| 4658 |
template <class Key, class Hash, class Pred, class Alloc>
|
| 4659 |
void swap(unordered_set<Key, Hash, Pred, Alloc>& x,
|
| 4660 |
unordered_set<Key, Hash, Pred, Alloc>& y);
|
| 4661 |
|
| 4662 |
+
template <class Key, class Hash, class Pred, class Alloc>
|
| 4663 |
+
bool operator==(const unordered_set<Key, Hash, Pred, Alloc>& a,
|
| 4664 |
+
const unordered_set<Key, Hash, Pred, Alloc>& b);
|
| 4665 |
+
template <class Key, class Hash, class Pred, class Alloc>
|
| 4666 |
+
bool operator!=(const unordered_set<Key, Hash, Pred, Alloc>& a,
|
| 4667 |
+
const unordered_set<Key, Hash, Pred, Alloc>& b);
|
| 4668 |
}
|
| 4669 |
```
|
| 4670 |
|
| 4671 |
#### `unordered_set` constructors <a id="unord.set.cnstr">[[unord.set.cnstr]]</a>
|
| 4672 |
|
| 4673 |
``` cpp
|
| 4674 |
+
unordered_set() : unordered_set(size_type(see below)) { }
|
| 4675 |
+
explicit unordered_set(size_type n,
|
| 4676 |
const hasher& hf = hasher(),
|
| 4677 |
const key_equal& eql = key_equal(),
|
| 4678 |
const allocator_type& a = allocator_type());
|
| 4679 |
```
|
| 4680 |
|
| 4681 |
*Effects:* Constructs an empty `unordered_set` using the specified hash
|
| 4682 |
function, key equality function, and allocator, and using at least *`n`*
|
| 4683 |
+
buckets. For the default constructor, the number of buckets is
|
| 4684 |
*implementation-defined*. `max_load_factor()` returns 1.0.
|
| 4685 |
|
| 4686 |
*Complexity:* Constant.
|
| 4687 |
|
| 4688 |
``` cpp
|
|
|
|
| 4749 |
typedef Key key_type;
|
| 4750 |
typedef Key value_type;
|
| 4751 |
typedef Hash hasher;
|
| 4752 |
typedef Pred key_equal;
|
| 4753 |
typedef Allocator allocator_type;
|
| 4754 |
+
typedef typename allocator_traits<Allocator>::pointer pointer;
|
| 4755 |
+
typedef typename allocator_traits<Allocator>::const_pointer const_pointer;
|
| 4756 |
+
typedef value_type& reference;
|
| 4757 |
+
typedef const value_type& const_reference;
|
| 4758 |
typedef implementation-defined size_type;
|
| 4759 |
typedef implementation-defined difference_type;
|
| 4760 |
|
| 4761 |
typedef implementation-defined iterator;
|
| 4762 |
typedef implementation-defined const_iterator;
|
| 4763 |
typedef implementation-defined local_iterator;
|
| 4764 |
typedef implementation-defined const_local_iterator;
|
| 4765 |
|
| 4766 |
// construct/destroy/copy
|
| 4767 |
+
unordered_multiset();
|
| 4768 |
+
explicit unordered_multiset(size_type n,
|
| 4769 |
const hasher& hf = hasher(),
|
| 4770 |
const key_equal& eql = key_equal(),
|
| 4771 |
const allocator_type& a = allocator_type());
|
| 4772 |
template <class InputIterator>
|
| 4773 |
unordered_multiset(InputIterator f, InputIterator l,
|
|
|
|
| 4783 |
unordered_multiset(initializer_list<value_type>,
|
| 4784 |
size_type = see below,
|
| 4785 |
const hasher& hf = hasher(),
|
| 4786 |
const key_equal& eql = key_equal(),
|
| 4787 |
const allocator_type& a = allocator_type());
|
| 4788 |
+
unordered_multiset(size_type n, const allocator_type& a)
|
| 4789 |
+
: unordered_multiset(n, hasher(), key_equal(), a) { }
|
| 4790 |
+
unordered_multiset(size_type n, const hasher& hf, const allocator_type& a)
|
| 4791 |
+
: unordered_multiset(n, hf, key_equal(), a) { }
|
| 4792 |
+
template <class InputIterator>
|
| 4793 |
+
unordered_multiset(InputIterator f, InputIterator l, size_type n, const allocator_type& a)
|
| 4794 |
+
: unordered_multiset(f, l, n, hasher(), key_equal(), a) { }
|
| 4795 |
+
template <class InputIterator>
|
| 4796 |
+
unordered_multiset(InputIterator f, InputIterator l, size_type n, const hasher& hf,
|
| 4797 |
+
const allocator_type& a)
|
| 4798 |
+
: unordered_multiset(f, l, n, hf, key_equal(), a) { }
|
| 4799 |
+
unordered_multiset(initializer_list<value_type> il, size_type n, const allocator_type& a)
|
| 4800 |
+
: unordered_multiset(il, n, hasher(), key_equal(), a) { }
|
| 4801 |
+
unordered_multiset(initializer_list<value_type> il, size_type n, const hasher& hf,
|
| 4802 |
+
const allocator_type& a)
|
| 4803 |
+
: unordered_multiset(il, n, hf, key_equal(), a) { }
|
| 4804 |
~unordered_multiset();
|
| 4805 |
unordered_multiset& operator=(const unordered_multiset&);
|
| 4806 |
+
unordered_multiset& operator=(unordered_multiset&&);
|
| 4807 |
unordered_multiset& operator=(initializer_list<value_type>);
|
| 4808 |
allocator_type get_allocator() const noexcept;
|
| 4809 |
|
| 4810 |
// size and capacity
|
| 4811 |
bool empty() const noexcept;
|
|
|
|
| 4869 |
};
|
| 4870 |
|
| 4871 |
template <class Key, class Hash, class Pred, class Alloc>
|
| 4872 |
void swap(unordered_multiset<Key, Hash, Pred, Alloc>& x,
|
| 4873 |
unordered_multiset<Key, Hash, Pred, Alloc>& y);
|
| 4874 |
+
template <class Key, class Hash, class Pred, class Alloc>
|
| 4875 |
+
bool operator==(const unordered_multiset<Key, Hash, Pred, Alloc>& a,
|
| 4876 |
+
const unordered_multiset<Key, Hash, Pred, Alloc>& b);
|
| 4877 |
+
template <class Key, class Hash, class Pred, class Alloc>
|
| 4878 |
+
bool operator!=(const unordered_multiset<Key, Hash, Pred, Alloc>& a,
|
| 4879 |
+
const unordered_multiset<Key, Hash, Pred, Alloc>& b);
|
| 4880 |
}
|
| 4881 |
```
|
| 4882 |
|
| 4883 |
#### `unordered_multiset` constructors <a id="unord.multiset.cnstr">[[unord.multiset.cnstr]]</a>
|
| 4884 |
|
| 4885 |
``` cpp
|
| 4886 |
+
unordered_multiset() : unordered_multiset(size_type(see below)) { }
|
| 4887 |
+
explicit unordered_multiset(size_type n,
|
| 4888 |
const hasher& hf = hasher(),
|
| 4889 |
const key_equal& eql = key_equal(),
|
| 4890 |
const allocator_type& a = allocator_type());
|
| 4891 |
```
|
| 4892 |
|
| 4893 |
*Effects:* Constructs an empty `unordered_multiset` using the specified
|
| 4894 |
hash function, key equality function, and allocator, and using at least
|
| 4895 |
+
*`n`* buckets. For the default constructor, the number of buckets is
|
| 4896 |
*implementation-defined*. `max_load_factor()` returns 1.0.
|
| 4897 |
|
| 4898 |
*Complexity:* Constant.
|
| 4899 |
|
| 4900 |
``` cpp
|
|
|
|
| 4927 |
## Container adaptors <a id="container.adaptors">[[container.adaptors]]</a>
|
| 4928 |
|
| 4929 |
### In general <a id="container.adaptors.general">[[container.adaptors.general]]</a>
|
| 4930 |
|
| 4931 |
The headers `<queue>` and `<stack>` define the container adaptors
|
| 4932 |
+
`queue`, `priority_queue`, and `stack`.
|
|
|
|
| 4933 |
|
| 4934 |
The container adaptors each take a `Container` template parameter, and
|
| 4935 |
each constructor takes a `Container` reference argument. This container
|
| 4936 |
is copied into the `Container` member of each adaptor. If the container
|
| 4937 |
takes an allocator, then a compatible allocator may be passed in to the
|
|
|
|
| 5447 |
bool operator> (const stack<T, Container>& x, const stack<T, Container>& y);
|
| 5448 |
template <class T, class Container>
|
| 5449 |
bool operator>=(const stack<T, Container>& x, const stack<T, Container>& y);
|
| 5450 |
template <class T, class Container>
|
| 5451 |
bool operator<=(const stack<T, Container>& x, const stack<T, Container>& y);
|
| 5452 |
+
template <class T, class Container>
|
| 5453 |
+
void swap(stack<T, Container>& x, stack<T, Container>& y) noexcept(noexcept(x.swap(y)));
|
| 5454 |
|
| 5455 |
template <class T, class Container, class Alloc>
|
| 5456 |
struct uses_allocator<stack<T, Container>, Alloc>
|
| 5457 |
: uses_allocator<Container, Alloc>::type { };
|
| 5458 |
}
|
|
|
|
| 5465 |
```
|
| 5466 |
|
| 5467 |
*Effects:* Initializes `c` with `cont`.
|
| 5468 |
|
| 5469 |
``` cpp
|
| 5470 |
+
explicit stack(Container&& cont = Container());
|
| 5471 |
```
|
| 5472 |
|
| 5473 |
*Effects:* Initializes `c` with `std::move(cont)`.
|
| 5474 |
|
| 5475 |
#### `stack` constructors with allocators <a id="stack.cons.alloc">[[stack.cons.alloc]]</a>
|
|
|
|
| 5576 |
|
| 5577 |
*Effects:* `x.swap(y)`.
|
| 5578 |
|
| 5579 |
<!-- Link reference definitions -->
|
| 5580 |
[alg.sorting]: algorithms.md#alg.sorting
|
| 5581 |
+
[algorithm.stable]: library.md#algorithm.stable
|
| 5582 |
[algorithms]: algorithms.md#algorithms
|
| 5583 |
[allocator.requirements]: library.md#allocator.requirements
|
| 5584 |
[allocator.traits.members]: utilities.md#allocator.traits.members
|
| 5585 |
[array]: #array
|
| 5586 |
[array.cons]: #array.cons
|
|
|
|
| 5636 |
[list.special]: #list.special
|
| 5637 |
[map]: #map
|
| 5638 |
[map.access]: #map.access
|
| 5639 |
[map.cons]: #map.cons
|
| 5640 |
[map.modifiers]: #map.modifiers
|
|
|
|
| 5641 |
[map.overview]: #map.overview
|
| 5642 |
[map.special]: #map.special
|
| 5643 |
[multimap]: #multimap
|
| 5644 |
[multimap.cons]: #multimap.cons
|
| 5645 |
[multimap.modifiers]: #multimap.modifiers
|
|
|
|
| 5646 |
[multimap.overview]: #multimap.overview
|
| 5647 |
[multimap.special]: #multimap.special
|
| 5648 |
[multiset]: #multiset
|
| 5649 |
[multiset.cons]: #multiset.cons
|
| 5650 |
[multiset.overview]: #multiset.overview
|
|
|
|
| 5684 |
[tab:containers.lib.summary]: #tab:containers.lib.summary
|
| 5685 |
[tab:containers.optional.operations]: #tab:containers.optional.operations
|
| 5686 |
[tab:containers.reversible.requirements]: #tab:containers.reversible.requirements
|
| 5687 |
[tab:containers.sequence.optional]: #tab:containers.sequence.optional
|
| 5688 |
[tab:containers.sequence.requirements]: #tab:containers.sequence.requirements
|
| 5689 |
+
[temp.deduct]: temp.md#temp.deduct
|
| 5690 |
[unord]: #unord
|
| 5691 |
[unord.general]: #unord.general
|
| 5692 |
[unord.hash]: utilities.md#unord.hash
|
| 5693 |
[unord.map]: #unord.map
|
| 5694 |
[unord.map.cnstr]: #unord.map.cnstr
|