- tmp/tmp27by8emx/{from.md → to.md} +234 -200
tmp/tmp27by8emx/{from.md → to.md}
RENAMED
|
@@ -25,15 +25,15 @@ for internal types used by the container.
|
|
| 25 |
|
| 26 |
[*Note 1*: This means, for example, that a node-based container would
|
| 27 |
need to construct nodes containing aligned buffers and call `construct`
|
| 28 |
to place the element into the buffer. — *end note*]
|
| 29 |
|
| 30 |
-
### General containers <a id="container.
|
| 31 |
|
| 32 |
-
####
|
| 33 |
|
| 34 |
-
In
|
| 35 |
|
| 36 |
- `X` denotes a container class containing objects of type `T`,
|
| 37 |
- `a` denotes a value of type `X`,
|
| 38 |
- `b` and `c` denote values of type (possibly const) `X`,
|
| 39 |
- `i` and `j` denote values of type (possibly const) `X::iterator`,
|
|
@@ -50,11 +50,11 @@ containers:
|
|
| 50 |
template<class R, class T>
|
| 51 |
concept container-compatible-range = // exposition only
|
| 52 |
ranges::input_range<R> && convertible_to<ranges::range_reference_t<R>, T>;
|
| 53 |
```
|
| 54 |
|
| 55 |
-
####
|
| 56 |
|
| 57 |
A type `X` meets the *container* requirements if the following types,
|
| 58 |
statements, and expressions are well-formed and have the specified
|
| 59 |
semantics.
|
| 60 |
|
|
@@ -134,15 +134,15 @@ X u = rv;
|
|
| 134 |
```
|
| 135 |
|
| 136 |
*Ensures:* `u` is equal to the value that `rv` had before this
|
| 137 |
construction.
|
| 138 |
|
| 139 |
-
*Complexity:* Linear for `array` and
|
| 140 |
-
containers.
|
| 141 |
|
| 142 |
``` cpp
|
| 143 |
-
t = v
|
| 144 |
```
|
| 145 |
|
| 146 |
*Result:* `X&`.
|
| 147 |
|
| 148 |
*Ensures:* `t == v`.
|
|
@@ -255,12 +255,12 @@ t.swap(s)
|
|
| 255 |
|
| 256 |
*Result:* `void`.
|
| 257 |
|
| 258 |
*Effects:* Exchanges the contents of `t` and `s`.
|
| 259 |
|
| 260 |
-
*Complexity:* Linear for `array` and
|
| 261 |
-
containers.
|
| 262 |
|
| 263 |
``` cpp
|
| 264 |
swap(t, s)
|
| 265 |
```
|
| 266 |
|
|
@@ -342,11 +342,11 @@ these container types take a `const allocator_type&` argument.
|
|
| 342 |
[*Note 2*: If an invocation of a constructor uses the default value of
|
| 343 |
an optional allocator argument, then the allocator type must support
|
| 344 |
value-initialization. — *end note*]
|
| 345 |
|
| 346 |
A copy of this allocator is used for any memory allocation and element
|
| 347 |
-
construction performed, by these constructors and by all member
|
| 348 |
functions, during the lifetime of each container object or until the
|
| 349 |
allocator is replaced. The allocator may be replaced only via assignment
|
| 350 |
or `swap()`. Allocator replacement is performed by copy assignment, move
|
| 351 |
assignment, or swapping of the allocator only if
|
| 352 |
|
|
@@ -360,15 +360,15 @@ operation. In all container types defined in this Clause, the member
|
|
| 360 |
`get_allocator()` returns a copy of the allocator used to construct the
|
| 361 |
container or, if that allocator has been replaced, a copy of the most
|
| 362 |
recent replacement.
|
| 363 |
|
| 364 |
The expression `a.swap(b)`, for containers `a` and `b` of a standard
|
| 365 |
-
container type other than `array`
|
| 366 |
-
`b` without invoking any move, copy, or swap
|
| 367 |
-
individual container elements. Any `Compare`, `Pred`,
|
| 368 |
-
belonging to `a` and `b` shall meet the *Cpp17Swappable*
|
| 369 |
-
and shall be exchanged by calling `swap` as described in
|
| 370 |
[[swappable.requirements]]. If
|
| 371 |
`allocator_traits<allocator_type>::propagate_on_container_swap::value`
|
| 372 |
is `true`, then `allocator_type` shall meet the *Cpp17Swappable*
|
| 373 |
requirements and the allocators of `a` and `b` shall also be exchanged
|
| 374 |
by calling `swap` as described in [[swappable.requirements]].
|
|
@@ -378,13 +378,13 @@ iterator referring to an element in one container before the swap shall
|
|
| 378 |
refer to the same element in the other container after the swap. It is
|
| 379 |
unspecified whether an iterator with value `a.end()` before the swap
|
| 380 |
will have value `b.end()` after the swap.
|
| 381 |
|
| 382 |
Unless otherwise specified (see [[associative.reqmts.except]],
|
| 383 |
-
[[unord.req.except]], [[deque.modifiers]],
|
| 384 |
-
container types defined in this Clause
|
| 385 |
-
requirements:
|
| 386 |
|
| 387 |
- If an exception is thrown by an `insert()` or `emplace()` function
|
| 388 |
while inserting a single element, that function has no effects.
|
| 389 |
- If an exception is thrown by a `push_back()`, `push_front()`,
|
| 390 |
`emplace_back()`, or `emplace_front()` function, that function has no
|
|
@@ -500,13 +500,13 @@ are implemented by constexpr functions.
|
|
| 500 |
a <=> b
|
| 501 |
```
|
| 502 |
|
| 503 |
*Result:* *`synth-three-way-result`*`<X::value_type>`.
|
| 504 |
|
| 505 |
-
*Preconditions:* Either `
|
| 506 |
-
|
| 507 |
-
|
| 508 |
|
| 509 |
*Returns:*
|
| 510 |
`lexicographical_compare_three_way(a.begin(), a.end(), b.begin(), b.end(), `*`synth-three-way`*`)`
|
| 511 |
|
| 512 |
[*Note 1*: The algorithm `lexicographical_compare_three_way` is defined
|
|
@@ -514,23 +514,25 @@ in [[algorithms]]. — *end note*]
|
|
| 514 |
|
| 515 |
*Complexity:* Linear.
|
| 516 |
|
| 517 |
#### Allocator-aware containers <a id="container.alloc.reqmts">[[container.alloc.reqmts]]</a>
|
| 518 |
|
| 519 |
-
|
| 520 |
-
|
|
|
|
| 521 |
*allocator-aware container*, as described below.
|
| 522 |
|
| 523 |
Given an allocator type `A` and given a container type `X` having a
|
| 524 |
`value_type` identical to `T` and an `allocator_type` identical to
|
| 525 |
`allocator_traits<A>::rebind_alloc<T>` and given an lvalue `m` of type
|
| 526 |
-
`A`, a pointer `p` of type `T*`, an expression `v`
|
| 527 |
-
`const T`
|
| 528 |
-
|
| 529 |
-
|
| 530 |
-
`allocator<T>` — no allocator object
|
| 531 |
-
specializations of `allocator<T>` are not
|
|
|
|
| 532 |
|
| 533 |
- `T` is **Cpp17DefaultInsertable* into `X`* means that the following
|
| 534 |
expression is well-formed:
|
| 535 |
``` cpp
|
| 536 |
allocator_traits<A>::construct(m, p)
|
|
@@ -551,11 +553,11 @@ specializations of `allocator<T>` are not instantiated:
|
|
| 551 |
|
| 552 |
and its evaluation causes the following postcondition to hold: The
|
| 553 |
value of `*p` is equivalent to the value of `rv` before the
|
| 554 |
evaluation.
|
| 555 |
\[*Note 1*: `rv` remains a valid object. Its state is
|
| 556 |
-
unspecified — *end note*]
|
| 557 |
- `T` is **Cpp17CopyInsertable* into `X`* means that, in addition to `T`
|
| 558 |
being *Cpp17MoveInsertable* into `X`, the following expression is
|
| 559 |
well-formed:
|
| 560 |
``` cpp
|
| 561 |
allocator_traits<A>::construct(m, p, v)
|
|
@@ -635,11 +637,11 @@ X u(m);
|
|
| 635 |
X u(t, m);
|
| 636 |
```
|
| 637 |
|
| 638 |
*Preconditions:* `T` is *Cpp17CopyInsertable* into `X`.
|
| 639 |
|
| 640 |
-
*Ensures:* `u == t`, `u.get_allocator() == m`
|
| 641 |
|
| 642 |
*Complexity:* Linear.
|
| 643 |
|
| 644 |
``` cpp
|
| 645 |
X u(rv);
|
|
@@ -725,29 +727,22 @@ can result in a data race. As an exception to the general rule, for a
|
|
| 725 |
`y[1] = true`. — *end note*]
|
| 726 |
|
| 727 |
### Sequence containers <a id="sequence.reqmts">[[sequence.reqmts]]</a>
|
| 728 |
|
| 729 |
A sequence container organizes a finite set of objects, all of the same
|
| 730 |
-
type, into a strictly linear arrangement. The library provides
|
| 731 |
-
basic kinds of sequence containers: `vector`,
|
| 732 |
-
|
| 733 |
-
|
| 734 |
-
|
|
|
|
|
|
|
| 735 |
easy to construct abstract data types, such as `stack`s, `queue`s,
|
| 736 |
`flat_map`s, `flat_multimap`s, `flat_set`s, or `flat_multiset`s, out of
|
| 737 |
the basic sequence container kinds (or out of other program-defined
|
| 738 |
sequence containers).
|
| 739 |
|
| 740 |
-
[*Note 1*: The sequence containers offer the programmer different
|
| 741 |
-
complexity trade-offs. `vector` is appropriate in most circumstances.
|
| 742 |
-
`array` has a fixed size known during translation. `list` or
|
| 743 |
-
`forward_list` support frequent insertions and deletions from the middle
|
| 744 |
-
of the sequence. `deque` supports efficient insertions and deletions
|
| 745 |
-
taking place at the beginning or at the end of the sequence. When
|
| 746 |
-
choosing a container, remember `vector` is best; leave a comment to
|
| 747 |
-
explain if you choose from the rest! — *end note*]
|
| 748 |
-
|
| 749 |
In this subclause,
|
| 750 |
|
| 751 |
- `X` denotes a sequence container class,
|
| 752 |
- `a` denotes a value of type `X` containing elements of type `T`,
|
| 753 |
- `u` denotes the name of a variable being declared,
|
|
@@ -755,18 +750,18 @@ In this subclause,
|
|
| 755 |
`X::allocator_type` is valid and denotes a type [[temp.deduct]] and
|
| 756 |
`allocator<T>` if it doesn’t,
|
| 757 |
- `i` and `j` denote iterators that meet the *Cpp17InputIterator*
|
| 758 |
requirements and refer to elements implicitly convertible to
|
| 759 |
`value_type`,
|
| 760 |
-
-
|
| 761 |
- `rg` denotes a value of a type `R` that models
|
| 762 |
`container-compatible-range<T>`,
|
| 763 |
- `il` designates an object of type `initializer_list<value_type>`,
|
| 764 |
- `n` denotes a value of type `X::size_type`,
|
| 765 |
- `p` denotes a valid constant iterator to `a`,
|
| 766 |
- `q` denotes a valid dereferenceable constant iterator to `a`,
|
| 767 |
-
-
|
| 768 |
- `t` denotes an lvalue or a const rvalue of `X::value_type`, and
|
| 769 |
- `rv` denotes a non-const rvalue of `X::value_type`.
|
| 770 |
- `Args` denotes a template parameter pack;
|
| 771 |
- `args` denotes a function parameter pack with the pattern `Args&&`.
|
| 772 |
|
|
@@ -793,27 +788,34 @@ X u(i, j);
|
|
| 793 |
*Preconditions:* `T` is *Cpp17EmplaceConstructible* into `X` from `*i`.
|
| 794 |
For `vector`, if the iterator does not meet the *Cpp17ForwardIterator*
|
| 795 |
requirements [[forward.iterators]], `T` is also *Cpp17MoveInsertable*
|
| 796 |
into `X`.
|
| 797 |
|
| 798 |
-
*Effects:* Constructs a sequence container equal to the range
|
| 799 |
-
Each iterator in the range \[`i`, `j`) is dereferenced exactly
|
|
|
|
| 800 |
|
| 801 |
*Ensures:* `distance(u.begin(), u.end()) == distance(i, j)` is `true`.
|
| 802 |
|
| 803 |
``` cpp
|
| 804 |
X(from_range, rg)
|
| 805 |
```
|
| 806 |
|
| 807 |
*Preconditions:* `T` is *Cpp17EmplaceConstructible* into `X` from
|
| 808 |
-
`*ranges::begin(rg)`. For `vector`, if `R` models
|
| 809 |
-
`ranges::
|
| 810 |
-
|
|
|
|
| 811 |
|
| 812 |
*Effects:* Constructs a sequence container equal to the range `rg`. Each
|
| 813 |
iterator in the range `rg` is dereferenced exactly once.
|
| 814 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 815 |
*Ensures:* `distance(begin(), end()) == ranges::distance(rg)` is `true`.
|
| 816 |
|
| 817 |
``` cpp
|
| 818 |
X(il)
|
| 819 |
```
|
|
@@ -839,30 +841,29 @@ a.emplace(p, args)
|
|
| 839 |
```
|
| 840 |
|
| 841 |
*Result:* `iterator`.
|
| 842 |
|
| 843 |
*Preconditions:* `T` is *Cpp17EmplaceConstructible* into `X` from
|
| 844 |
-
`args`. For `vector` and `deque`, `T` is also
|
| 845 |
-
`X` and *Cpp17MoveAssignable*.
|
| 846 |
|
| 847 |
*Effects:* Inserts an object of type `T` constructed with
|
| 848 |
`std::forward<Args>(args)...` before `p`.
|
| 849 |
|
| 850 |
[*Note 1*: `args` can directly or indirectly refer to a value in
|
| 851 |
`a`. — *end note*]
|
| 852 |
|
| 853 |
-
*Returns:* An iterator that points to the new element
|
| 854 |
-
`args` into `a`.
|
| 855 |
|
| 856 |
``` cpp
|
| 857 |
a.insert(p, t)
|
| 858 |
```
|
| 859 |
|
| 860 |
*Result:* `iterator`.
|
| 861 |
|
| 862 |
-
*Preconditions:* `T` is *Cpp17CopyInsertable* into `X`. For `vector`
|
| 863 |
-
`deque`, `T` is also *Cpp17CopyAssignable*.
|
| 864 |
|
| 865 |
*Effects:* Inserts a copy of `t` before `p`.
|
| 866 |
|
| 867 |
*Returns:* An iterator that points to the copy of `t` inserted into `a`.
|
| 868 |
|
|
@@ -870,12 +871,12 @@ a.insert(p, t)
|
|
| 870 |
a.insert(p, rv)
|
| 871 |
```
|
| 872 |
|
| 873 |
*Result:* `iterator`.
|
| 874 |
|
| 875 |
-
*Preconditions:* `T` is *Cpp17MoveInsertable* into `X`. For `vector`
|
| 876 |
-
`deque`, `T` is also *Cpp17MoveAssignable*.
|
| 877 |
|
| 878 |
*Effects:* Inserts a copy of `rv` before `p`.
|
| 879 |
|
| 880 |
*Returns:* An iterator that points to the copy of `rv` inserted into
|
| 881 |
`a`.
|
|
@@ -899,16 +900,17 @@ a.insert(p, i, j)
|
|
| 899 |
```
|
| 900 |
|
| 901 |
*Result:* `iterator`.
|
| 902 |
|
| 903 |
*Preconditions:* `T` is *Cpp17EmplaceConstructible* into `X` from `*i`.
|
| 904 |
-
For `vector` and `deque`, `T` is also
|
| 905 |
-
and `T` meets the
|
|
|
|
| 906 |
*Cpp17Swappable*[[swappable.requirements]] requirements. Neither `i` nor
|
| 907 |
`j` are iterators into `a`.
|
| 908 |
|
| 909 |
-
*Effects:* Inserts copies of elements in
|
| 910 |
iterator in the range \[`i`, `j`) shall be dereferenced exactly once.
|
| 911 |
|
| 912 |
*Returns:* An iterator that points to the copy of the first element
|
| 913 |
inserted into `a`, or `p` if `i == j`.
|
| 914 |
|
|
@@ -917,12 +919,12 @@ a.insert_range(p, rg)
|
|
| 917 |
```
|
| 918 |
|
| 919 |
*Result:* `iterator`.
|
| 920 |
|
| 921 |
*Preconditions:* `T` is *Cpp17EmplaceConstructible* into `X` from
|
| 922 |
-
`*ranges::begin(rg)`. For `vector` and `deque`, `T`
|
| 923 |
-
*Cpp17MoveInsertable* into `X`, and `T` meets the
|
| 924 |
*Cpp17MoveConstructible*, *Cpp17MoveAssignable*, and
|
| 925 |
*Cpp17Swappable*[[swappable.requirements]] requirements. `rg` and `a` do
|
| 926 |
not overlap.
|
| 927 |
|
| 928 |
*Effects:* Inserts copies of elements in `rg` before `p`. Each iterator
|
|
@@ -941,11 +943,12 @@ a.insert(p, il)
|
|
| 941 |
a.erase(q)
|
| 942 |
```
|
| 943 |
|
| 944 |
*Result:* `iterator`.
|
| 945 |
|
| 946 |
-
*Preconditions:* For `vector` and `deque`, `T` is
|
|
|
|
| 947 |
|
| 948 |
*Effects:* Erases the element pointed to by `q`.
|
| 949 |
|
| 950 |
*Returns:* An iterator that points to the element immediately following
|
| 951 |
`q` prior to the element being erased. If no such element exists,
|
|
@@ -955,13 +958,14 @@ a.erase(q)
|
|
| 955 |
a.erase(q1, q2)
|
| 956 |
```
|
| 957 |
|
| 958 |
*Result:* `iterator`.
|
| 959 |
|
| 960 |
-
*Preconditions:* For `vector` and `deque`, `T` is
|
|
|
|
| 961 |
|
| 962 |
-
*Effects:* Erases the elements in the range
|
| 963 |
|
| 964 |
*Returns:* An iterator that points to the element pointed to by `q2`
|
| 965 |
prior to any elements being erased. If no such element exists, `a.end()`
|
| 966 |
is returned.
|
| 967 |
|
|
@@ -989,14 +993,15 @@ a.assign(i, j)
|
|
| 989 |
and assignable from `*i`. For `vector`, if the iterator does not meet
|
| 990 |
the forward iterator requirements [[forward.iterators]], `T` is also
|
| 991 |
*Cpp17MoveInsertable* into `X`. Neither `i` nor `j` are iterators into
|
| 992 |
`a`.
|
| 993 |
|
| 994 |
-
*Effects:* Replaces elements in `a` with a copy of
|
| 995 |
-
all references, pointers and iterators referring to the
|
| 996 |
-
For `vector` and `deque`, also invalidates the
|
| 997 |
-
Each iterator in the range \[`i`, `j`) is
|
|
|
|
| 998 |
|
| 999 |
``` cpp
|
| 1000 |
a.assign_range(rg)
|
| 1001 |
```
|
| 1002 |
|
|
@@ -1004,20 +1009,26 @@ a.assign_range(rg)
|
|
| 1004 |
|
| 1005 |
*Mandates:* `assignable_from<T&, ranges::range_reference_t<R>>` is
|
| 1006 |
modeled.
|
| 1007 |
|
| 1008 |
*Preconditions:* `T` is *Cpp17EmplaceConstructible* into `X` from
|
| 1009 |
-
`*ranges::begin(rg)`. For `vector`, if `R` models
|
| 1010 |
-
`ranges::
|
| 1011 |
-
|
|
|
|
| 1012 |
|
| 1013 |
*Effects:* Replaces elements in `a` with a copy of each element in `rg`.
|
| 1014 |
Invalidates all references, pointers, and iterators referring to the
|
| 1015 |
elements of `a`. For `vector` and `deque`, also invalidates the
|
| 1016 |
past-the-end iterator. Each iterator in the range `rg` is dereferenced
|
| 1017 |
exactly once.
|
| 1018 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1019 |
``` cpp
|
| 1020 |
a.assign(il)
|
| 1021 |
```
|
| 1022 |
|
| 1023 |
*Effects:* Equivalent to `a.assign(il.begin(), il.end())`.
|
|
@@ -1079,31 +1090,35 @@ containers but not others. Operations other than `prepend_range` and
|
|
| 1079 |
a.front()
|
| 1080 |
```
|
| 1081 |
|
| 1082 |
*Result:* `reference; const_reference` for constant `a`.
|
| 1083 |
|
|
|
|
|
|
|
| 1084 |
*Returns:* `*a.begin()`
|
| 1085 |
|
| 1086 |
*Remarks:* Required for `basic_string`, `array`, `deque`,
|
| 1087 |
-
`forward_list`, `list`, and `vector`.
|
| 1088 |
|
| 1089 |
``` cpp
|
| 1090 |
a.back()
|
| 1091 |
```
|
| 1092 |
|
| 1093 |
*Result:* `reference; const_reference` for constant `a`.
|
| 1094 |
|
|
|
|
|
|
|
| 1095 |
*Effects:* Equivalent to:
|
| 1096 |
|
| 1097 |
``` cpp
|
| 1098 |
auto tmp = a.end();
|
| 1099 |
--tmp;
|
| 1100 |
return *tmp;
|
| 1101 |
```
|
| 1102 |
|
| 1103 |
-
*Remarks:* Required for `basic_string`, `array`, `deque`,
|
| 1104 |
-
`vector`.
|
| 1105 |
|
| 1106 |
``` cpp
|
| 1107 |
a.emplace_front(args)
|
| 1108 |
```
|
| 1109 |
|
|
@@ -1131,11 +1146,11 @@ a.emplace_back(args)
|
|
| 1131 |
*Effects:* Appends an object of type `T` constructed with
|
| 1132 |
`std::forward<Args>(args)...`.
|
| 1133 |
|
| 1134 |
*Returns:* `a.back()`.
|
| 1135 |
|
| 1136 |
-
*Remarks:* Required for `deque`, `list`, and `vector`.
|
| 1137 |
|
| 1138 |
``` cpp
|
| 1139 |
a.push_front(t)
|
| 1140 |
```
|
| 1141 |
|
|
@@ -1187,11 +1202,12 @@ a.push_back(t)
|
|
| 1187 |
|
| 1188 |
*Preconditions:* `T` is *Cpp17CopyInsertable* into `X`.
|
| 1189 |
|
| 1190 |
*Effects:* Appends a copy of `t`.
|
| 1191 |
|
| 1192 |
-
*Remarks:* Required for `basic_string`, `deque`, `
|
|
|
|
| 1193 |
|
| 1194 |
``` cpp
|
| 1195 |
a.push_back(rv)
|
| 1196 |
```
|
| 1197 |
|
|
@@ -1199,11 +1215,12 @@ a.push_back(rv)
|
|
| 1199 |
|
| 1200 |
*Preconditions:* `T` is *Cpp17MoveInsertable* into `X`.
|
| 1201 |
|
| 1202 |
*Effects:* Appends a copy of `rv`.
|
| 1203 |
|
| 1204 |
-
*Remarks:* Required for `basic_string`, `deque`, `
|
|
|
|
| 1205 |
|
| 1206 |
``` cpp
|
| 1207 |
a.append_range(rg)
|
| 1208 |
```
|
| 1209 |
|
|
@@ -1214,19 +1231,19 @@ a.append_range(rg)
|
|
| 1214 |
into `X`.
|
| 1215 |
|
| 1216 |
*Effects:* Inserts copies of elements in `rg` before `end()`. Each
|
| 1217 |
iterator in the range `rg` is dereferenced exactly once.
|
| 1218 |
|
| 1219 |
-
*Remarks:* Required for `deque`, `list`, and `vector`.
|
| 1220 |
|
| 1221 |
``` cpp
|
| 1222 |
a.pop_front()
|
| 1223 |
```
|
| 1224 |
|
| 1225 |
*Result:* `void`
|
| 1226 |
|
| 1227 |
-
|
| 1228 |
|
| 1229 |
*Effects:* Destroys the first element.
|
| 1230 |
|
| 1231 |
*Remarks:* Required for `deque`, `forward_list`, and `list`.
|
| 1232 |
|
|
@@ -1234,37 +1251,42 @@ a.pop_front()
|
|
| 1234 |
a.pop_back()
|
| 1235 |
```
|
| 1236 |
|
| 1237 |
*Result:* `void`
|
| 1238 |
|
| 1239 |
-
|
| 1240 |
|
| 1241 |
*Effects:* Destroys the last element.
|
| 1242 |
|
| 1243 |
-
*Remarks:* Required for `basic_string`, `deque`, `
|
|
|
|
| 1244 |
|
| 1245 |
``` cpp
|
| 1246 |
a[n]
|
| 1247 |
```
|
| 1248 |
|
| 1249 |
-
*Result:* `reference; const_reference` for constant `a`
|
| 1250 |
|
| 1251 |
-
|
| 1252 |
|
| 1253 |
-
*
|
|
|
|
|
|
|
|
|
|
| 1254 |
|
| 1255 |
``` cpp
|
| 1256 |
a.at(n)
|
| 1257 |
```
|
| 1258 |
|
| 1259 |
-
*Result:* `reference; const_reference` for constant `a`
|
| 1260 |
|
| 1261 |
*Returns:* `*(a.begin() + n)`
|
| 1262 |
|
| 1263 |
*Throws:* `out_of_range` if `n >= a.size()`.
|
| 1264 |
|
| 1265 |
-
*Remarks:* Required for `basic_string`, `array`, `deque`,
|
|
|
|
| 1266 |
|
| 1267 |
### Node handles <a id="container.node">[[container.node]]</a>
|
| 1268 |
|
| 1269 |
#### Overview <a id="container.node.overview">[[container.node.overview]]</a>
|
| 1270 |
|
|
@@ -1310,167 +1332,170 @@ public:
|
|
| 1310 |
using key_type = see below; // not present for set containers
|
| 1311 |
using mapped_type = see below; // not present for set containers
|
| 1312 |
using allocator_type = see below;
|
| 1313 |
|
| 1314 |
private:
|
| 1315 |
-
using
|
| 1316 |
-
using
|
| 1317 |
|
| 1318 |
-
typename
|
| 1319 |
-
rebind_traits<
|
| 1320 |
optional<allocator_type> alloc_; // exposition only
|
| 1321 |
|
| 1322 |
public:
|
| 1323 |
// [container.node.cons], constructors, copy, and assignment
|
| 1324 |
constexpr node-handle() noexcept : ptr_(), alloc_() {}
|
| 1325 |
-
node-handle(node-handle&&) noexcept;
|
| 1326 |
-
node-handle& operator=(node-handle&&);
|
| 1327 |
|
| 1328 |
// [container.node.dtor], destructor
|
| 1329 |
-
~node-handle();
|
| 1330 |
|
| 1331 |
// [container.node.observers], observers
|
| 1332 |
-
value_type& value() const;
|
| 1333 |
key_type& key() const; // not present for set containers
|
| 1334 |
-
mapped_type& mapped() const;
|
| 1335 |
|
| 1336 |
-
allocator_type get_allocator() const;
|
| 1337 |
-
explicit operator bool() const noexcept;
|
| 1338 |
-
|
| 1339 |
|
| 1340 |
// [container.node.modifiers], modifiers
|
| 1341 |
-
void swap(node-handle&)
|
| 1342 |
-
noexcept(
|
| 1343 |
-
|
| 1344 |
|
| 1345 |
-
friend void swap(node-handle& x, node-handle& y) noexcept(noexcept(x.swap(y))) {
|
| 1346 |
x.swap(y);
|
| 1347 |
}
|
| 1348 |
};
|
| 1349 |
```
|
| 1350 |
|
| 1351 |
#### Constructors, copy, and assignment <a id="container.node.cons">[[container.node.cons]]</a>
|
| 1352 |
|
| 1353 |
``` cpp
|
| 1354 |
-
node-handle(node-handle&& nh) noexcept;
|
| 1355 |
```
|
| 1356 |
|
| 1357 |
-
*Effects:* Constructs a *node-handle* object initializing
|
| 1358 |
-
`nh.ptr_`. Move constructs
|
| 1359 |
-
to `nh.ptr_` and assigns `nullopt` to `nh.alloc_`.
|
| 1360 |
|
| 1361 |
``` cpp
|
| 1362 |
-
node-handle& operator=(node-handle&& nh);
|
| 1363 |
```
|
| 1364 |
|
| 1365 |
-
*Preconditions:* Either `!alloc_`, or
|
| 1366 |
-
`
|
| 1367 |
-
or `alloc_ == nh.alloc_`.
|
| 1368 |
|
| 1369 |
*Effects:*
|
| 1370 |
|
| 1371 |
-
- If `ptr_ != nullptr`, destroys the `value_type`
|
| 1372 |
-
|
| 1373 |
-
`
|
| 1374 |
-
|
| 1375 |
-
-
|
| 1376 |
-
-
|
| 1377 |
-
|
| 1378 |
-
`
|
| 1379 |
-
|
|
|
|
|
|
|
| 1380 |
|
| 1381 |
*Returns:* `*this`.
|
| 1382 |
|
| 1383 |
*Throws:* Nothing.
|
| 1384 |
|
| 1385 |
#### Destructor <a id="container.node.dtor">[[container.node.dtor]]</a>
|
| 1386 |
|
| 1387 |
``` cpp
|
| 1388 |
-
~node-handle();
|
| 1389 |
```
|
| 1390 |
|
| 1391 |
-
*Effects:* If `ptr_ != nullptr`, destroys the `value_type`
|
| 1392 |
-
the
|
| 1393 |
-
`
|
| 1394 |
-
`
|
| 1395 |
|
| 1396 |
#### Observers <a id="container.node.observers">[[container.node.observers]]</a>
|
| 1397 |
|
| 1398 |
``` cpp
|
| 1399 |
-
value_type& value() const;
|
| 1400 |
```
|
| 1401 |
|
| 1402 |
*Preconditions:* `empty() == false`.
|
| 1403 |
|
| 1404 |
*Returns:* A reference to the `value_type` subobject in the
|
| 1405 |
-
|
| 1406 |
|
| 1407 |
*Throws:* Nothing.
|
| 1408 |
|
| 1409 |
``` cpp
|
| 1410 |
key_type& key() const;
|
| 1411 |
```
|
| 1412 |
|
| 1413 |
*Preconditions:* `empty() == false`.
|
| 1414 |
|
| 1415 |
*Returns:* A non-const reference to the `key_type` member of the
|
| 1416 |
-
`value_type` subobject in the
|
| 1417 |
-
|
| 1418 |
|
| 1419 |
*Throws:* Nothing.
|
| 1420 |
|
| 1421 |
*Remarks:* Modifying the key through the returned reference is
|
| 1422 |
permitted.
|
| 1423 |
|
| 1424 |
``` cpp
|
| 1425 |
-
mapped_type& mapped() const;
|
| 1426 |
```
|
| 1427 |
|
| 1428 |
*Preconditions:* `empty() == false`.
|
| 1429 |
|
| 1430 |
*Returns:* A reference to the `mapped_type` member of the `value_type`
|
| 1431 |
-
subobject in the
|
| 1432 |
|
| 1433 |
*Throws:* Nothing.
|
| 1434 |
|
| 1435 |
``` cpp
|
| 1436 |
-
allocator_type get_allocator() const;
|
| 1437 |
```
|
| 1438 |
|
| 1439 |
*Preconditions:* `empty() == false`.
|
| 1440 |
|
| 1441 |
-
*Returns:* `*alloc_`.
|
| 1442 |
|
| 1443 |
*Throws:* Nothing.
|
| 1444 |
|
| 1445 |
``` cpp
|
| 1446 |
-
explicit operator bool() const noexcept;
|
| 1447 |
```
|
| 1448 |
|
| 1449 |
-
*Returns:* `ptr_ != nullptr`.
|
| 1450 |
|
| 1451 |
``` cpp
|
| 1452 |
-
|
| 1453 |
```
|
| 1454 |
|
| 1455 |
-
*Returns:* `ptr_ == nullptr`.
|
| 1456 |
|
| 1457 |
#### Modifiers <a id="container.node.modifiers">[[container.node.modifiers]]</a>
|
| 1458 |
|
| 1459 |
``` cpp
|
| 1460 |
-
void swap(node-handle& nh)
|
| 1461 |
-
noexcept(
|
| 1462 |
-
|
| 1463 |
```
|
| 1464 |
|
| 1465 |
-
*Preconditions:* `!alloc_`, or `!nh.alloc_`, or
|
| 1466 |
-
`
|
| 1467 |
-
`alloc_ == nh.alloc_`.
|
| 1468 |
|
| 1469 |
-
*Effects:* Calls `swap(ptr_, nh.ptr_)`. If `!
|
| 1470 |
-
or `
|
| 1471 |
-
`
|
|
|
|
| 1472 |
|
| 1473 |
### Insert return type <a id="container.insert.return">[[container.insert.return]]</a>
|
| 1474 |
|
| 1475 |
The associative containers with unique keys and the unordered containers
|
| 1476 |
with unique keys have a member function `insert` that returns a nested
|
|
@@ -1485,11 +1510,11 @@ struct insert-return-type
|
|
| 1485 |
bool inserted;
|
| 1486 |
NodeType node;
|
| 1487 |
};
|
| 1488 |
```
|
| 1489 |
|
| 1490 |
-
The name *`insert-return-type`* is exposition only.
|
| 1491 |
*`insert-return-type`* has the template parameters, data members, and
|
| 1492 |
special members specified above. It has no base classes or members other
|
| 1493 |
than those specified.
|
| 1494 |
|
| 1495 |
### Associative containers <a id="associative.reqmts">[[associative.reqmts]]</a>
|
|
@@ -1548,14 +1573,14 @@ In this subclause,
|
|
| 1548 |
|
| 1549 |
- `X` denotes an associative container class,
|
| 1550 |
- `a` denotes a value of type `X`,
|
| 1551 |
- `a2` denotes a value of a type with nodes compatible with type `X` (
|
| 1552 |
[[container.node.compat]]),
|
| 1553 |
-
- `b` denotes a value
|
| 1554 |
- `u` denotes the name of a variable being declared,
|
| 1555 |
- `a_uniq` denotes a value of type `X` when `X` supports unique keys,
|
| 1556 |
-
- `a_eq` denotes a value of type `X` when `X` supports
|
| 1557 |
- `a_tran` denotes a value of type `X` or `const X` when the
|
| 1558 |
*qualified-id* `X::key_compare::is_transparent` is valid and denotes a
|
| 1559 |
type [[temp.deduct]],
|
| 1560 |
- `i` and `j` meet the *Cpp17InputIterator* requirements and refer to
|
| 1561 |
elements implicitly convertible to `value_type`,
|
|
@@ -1563,11 +1588,11 @@ In this subclause,
|
|
| 1563 |
- `rg` denotes a value of a type `R` that models
|
| 1564 |
`container-compatible-range<value_type>`,
|
| 1565 |
- `p` denotes a valid constant iterator to `a`,
|
| 1566 |
- `q` denotes a valid dereferenceable constant iterator to `a`,
|
| 1567 |
- `r` denotes a valid dereferenceable iterator to `a`,
|
| 1568 |
-
-
|
| 1569 |
- `il` designates an object of type `initializer_list<value_type>`,
|
| 1570 |
- `t` denotes a value of type `X::value_type`,
|
| 1571 |
- `k` denotes a value of type `X::key_type`, and
|
| 1572 |
- `c` denotes a value of type `X::key_compare` or
|
| 1573 |
`const X::key_compare`;
|
|
@@ -1589,19 +1614,18 @@ In this subclause,
|
|
| 1589 |
- `m` denotes an allocator of a type convertible to `A`, and `nh`
|
| 1590 |
denotes a non-const rvalue of type `X::node_type`.
|
| 1591 |
|
| 1592 |
A type `X` meets the *associative container* requirements if `X` meets
|
| 1593 |
all the requirements of an allocator-aware container
|
| 1594 |
-
[[container.
|
| 1595 |
-
|
| 1596 |
that for `map` and `multimap`, the requirements placed on `value_type`
|
| 1597 |
-
in [[container.
|
| 1598 |
-
`mapped_type`.
|
| 1599 |
|
| 1600 |
-
[*Note 3*: For example, in some cases `key_type` and `mapped_type`
|
| 1601 |
-
|
| 1602 |
-
`
|
| 1603 |
*Cpp17CopyAssignable*. — *end note*]
|
| 1604 |
|
| 1605 |
``` cpp
|
| 1606 |
typename X::key_type
|
| 1607 |
```
|
|
@@ -1820,12 +1844,11 @@ a.emplace_hint(p, args)
|
|
| 1820 |
|
| 1821 |
*Effects:* Equivalent to `a.emplace(std::forward<Args>(args)...)`,
|
| 1822 |
except that the element is inserted as close as possible to the position
|
| 1823 |
just prior to `p`.
|
| 1824 |
|
| 1825 |
-
*Returns:*
|
| 1826 |
-
to the newly inserted element.
|
| 1827 |
|
| 1828 |
*Complexity:* Logarithmic in general, but amortized constant if the
|
| 1829 |
element is inserted right before `p`.
|
| 1830 |
|
| 1831 |
``` cpp
|
|
@@ -2034,21 +2057,22 @@ a.extract(q)
|
|
| 2034 |
a.merge(a2)
|
| 2035 |
```
|
| 2036 |
|
| 2037 |
*Result:* `void`
|
| 2038 |
|
| 2039 |
-
*Preconditions:* `a.get_allocator() == a2.get_allocator()`.
|
| 2040 |
|
| 2041 |
*Effects:* Attempts to extract each element in `a2` and insert it into
|
| 2042 |
`a` using the comparison object of `a`. In containers with unique keys,
|
| 2043 |
if there is an element in `a` with key equivalent to the key of an
|
| 2044 |
element from `a2`, then that element is not extracted from `a2`.
|
| 2045 |
|
| 2046 |
*Ensures:* Pointers and references to the transferred elements of `a2`
|
| 2047 |
-
refer to those same elements but as members of `a`.
|
| 2048 |
-
|
| 2049 |
-
|
|
|
|
| 2050 |
|
| 2051 |
*Throws:* Nothing unless the comparison object throws.
|
| 2052 |
|
| 2053 |
*Complexity:* N log(`a.size()+` N), where N has the value `a2.size()`.
|
| 2054 |
|
|
@@ -2220,11 +2244,11 @@ b.upper_bound(k)
|
|
| 2220 |
*Result:* `iterator`; `const_iterator` for constant `b`.
|
| 2221 |
|
| 2222 |
*Returns:* An iterator pointing to the first element with key greater
|
| 2223 |
than `k`, or `b.end()` if such an element is not found.
|
| 2224 |
|
| 2225 |
-
*Complexity:* Logarithmic
|
| 2226 |
|
| 2227 |
``` cpp
|
| 2228 |
a_tran.upper_bound(ku)
|
| 2229 |
```
|
| 2230 |
|
|
@@ -2422,17 +2446,17 @@ In this subclause,
|
|
| 2422 |
- `a_tran` denotes a value of type `X` or `const X` when the
|
| 2423 |
*qualified-id*s `X::key_equal::is_transparent` and
|
| 2424 |
`X::hasher::is_transparent` are both valid and denote types
|
| 2425 |
[[temp.deduct]],
|
| 2426 |
- `i` and `j` denote input iterators that refer to `value_type`,
|
| 2427 |
-
-
|
| 2428 |
- `rg` denotes a value of a type `R` that models
|
| 2429 |
`container-compatible-range<value_type>`,
|
| 2430 |
- `p` and `q2` denote valid constant iterators to `a`,
|
| 2431 |
- `q` and `q1` denote valid dereferenceable constant iterators to `a`,
|
| 2432 |
- `r` denotes a valid dereferenceable iterator to `a`,
|
| 2433 |
-
-
|
| 2434 |
- `il` denotes a value of type `initializer_list<value_type>`,
|
| 2435 |
- `t` denotes a value of type `X::value_type`,
|
| 2436 |
- `k` denotes a value of type `key_type`,
|
| 2437 |
- `hf` denotes a value of type `hasher` or `const hasher`,
|
| 2438 |
- `eq` denotes a value of type `key_equal` or `const key_equal`,
|
|
@@ -2455,19 +2479,19 @@ In this subclause,
|
|
| 2455 |
- `z` denotes a value of type `float`, and
|
| 2456 |
- `nh` denotes an rvalue of type `X::node_type`.
|
| 2457 |
|
| 2458 |
A type `X` meets the *unordered associative container* requirements if
|
| 2459 |
`X` meets all the requirements of an allocator-aware container
|
| 2460 |
-
[[container.
|
| 2461 |
-
|
| 2462 |
that for `unordered_map` and `unordered_multimap`, the requirements
|
| 2463 |
-
placed on `value_type` in [[container.
|
| 2464 |
`key_type` and `mapped_type`.
|
| 2465 |
|
| 2466 |
-
[*Note 3*: For example, `key_type` and `mapped_type`
|
| 2467 |
-
|
| 2468 |
-
`
|
| 2469 |
*Cpp17CopyAssignable*. — *end note*]
|
| 2470 |
|
| 2471 |
``` cpp
|
| 2472 |
typename X::key_type
|
| 2473 |
```
|
|
@@ -2734,12 +2758,12 @@ X(il, n, hf, eq)
|
|
| 2734 |
``` cpp
|
| 2735 |
X(b)
|
| 2736 |
```
|
| 2737 |
|
| 2738 |
*Effects:* In addition to the container
|
| 2739 |
-
requirements [[container.
|
| 2740 |
-
|
| 2741 |
|
| 2742 |
*Complexity:* Average case linear in `b.size()`, worst case quadratic.
|
| 2743 |
|
| 2744 |
``` cpp
|
| 2745 |
a = b
|
|
@@ -2825,21 +2849,15 @@ from `args`.
|
|
| 2825 |
a.emplace_hint(p, args)
|
| 2826 |
```
|
| 2827 |
|
| 2828 |
*Result:* `iterator`
|
| 2829 |
|
| 2830 |
-
*
|
| 2831 |
-
|
|
|
|
| 2832 |
|
| 2833 |
-
*
|
| 2834 |
-
|
| 2835 |
-
*Returns:* An iterator pointing to the element with the key equivalent
|
| 2836 |
-
to the newly inserted element. The `const_iterator` `p` is a hint
|
| 2837 |
-
pointing to where the search should start. Implementations are permitted
|
| 2838 |
-
to ignore the hint.
|
| 2839 |
-
|
| 2840 |
-
*Complexity:* Average case 𝑂(1), worst case 𝑂(`a.size()`).
|
| 2841 |
|
| 2842 |
``` cpp
|
| 2843 |
a_uniq.insert(t)
|
| 2844 |
```
|
| 2845 |
|
|
@@ -2900,11 +2918,11 @@ a.insert(i, j)
|
|
| 2900 |
*Result:* `void`
|
| 2901 |
|
| 2902 |
*Preconditions:* `value_type` is *Cpp17EmplaceConstructible* into `X`
|
| 2903 |
from `*i`. Neither `i` nor `j` are iterators into `a`.
|
| 2904 |
|
| 2905 |
-
*Effects:* Equivalent to `a.insert(t)` for each element in
|
| 2906 |
|
| 2907 |
*Complexity:* Average case 𝑂(N), where N is `distance(i, j)`, worst case
|
| 2908 |
𝑂(N(`a.size()` + 1)).
|
| 2909 |
|
| 2910 |
``` cpp
|
|
@@ -3106,11 +3124,11 @@ a.erase(r)
|
|
| 3106 |
a.erase(q1, q2)
|
| 3107 |
```
|
| 3108 |
|
| 3109 |
*Result:* `iterator`
|
| 3110 |
|
| 3111 |
-
*Effects:* Erases all elements in the range
|
| 3112 |
|
| 3113 |
*Returns:* The iterator immediately following the erased elements prior
|
| 3114 |
to the erasure.
|
| 3115 |
|
| 3116 |
*Complexity:* Average case linear in `distance(q1, q2)`, worst case
|
|
@@ -3238,21 +3256,37 @@ b.bucket(k)
|
|
| 3238 |
|
| 3239 |
*Preconditions:* `b.bucket_count() > 0`.
|
| 3240 |
|
| 3241 |
*Returns:* The index of the bucket in which elements with keys
|
| 3242 |
equivalent to `k` would be found, if any such element existed. The
|
| 3243 |
-
return value is in the range
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3244 |
|
| 3245 |
*Complexity:* Constant.
|
| 3246 |
|
| 3247 |
``` cpp
|
| 3248 |
b.bucket_size(n)
|
| 3249 |
```
|
| 3250 |
|
| 3251 |
*Result:* `size_type`
|
| 3252 |
|
| 3253 |
-
*Preconditions:* `n` shall be in the range
|
| 3254 |
|
| 3255 |
*Returns:* The number of elements in the `n`ᵗʰ bucket.
|
| 3256 |
|
| 3257 |
*Complexity:* 𝑂(`b.bucket_size(n)`)
|
| 3258 |
|
|
@@ -3260,11 +3294,11 @@ b.bucket_size(n)
|
|
| 3260 |
b.begin(n)
|
| 3261 |
```
|
| 3262 |
|
| 3263 |
*Result:* `local_iterator`; `const_local_iterator` for constant `b`.
|
| 3264 |
|
| 3265 |
-
*Preconditions:* `n` is in the range
|
| 3266 |
|
| 3267 |
*Returns:* An iterator referring to the first element in the bucket. If
|
| 3268 |
the bucket is empty, then `b.begin(n) == b.end(n)`.
|
| 3269 |
|
| 3270 |
*Complexity:* Constant.
|
|
@@ -3273,11 +3307,11 @@ the bucket is empty, then `b.begin(n) == b.end(n)`.
|
|
| 3273 |
b.end(n)
|
| 3274 |
```
|
| 3275 |
|
| 3276 |
*Result:* `local_iterator`; `const_local_iterator` for constant `b`.
|
| 3277 |
|
| 3278 |
-
*Preconditions:* `n` is in the range
|
| 3279 |
|
| 3280 |
*Returns:* An iterator which is the past-the-end value for the bucket.
|
| 3281 |
|
| 3282 |
*Complexity:* Constant.
|
| 3283 |
|
|
@@ -3285,11 +3319,11 @@ b.end(n)
|
|
| 3285 |
b.cbegin(n)
|
| 3286 |
```
|
| 3287 |
|
| 3288 |
*Result:* `const_local_iterator`
|
| 3289 |
|
| 3290 |
-
*Preconditions:* `n` shall be in the range
|
| 3291 |
|
| 3292 |
*Returns:* An iterator referring to the first element in the bucket. If
|
| 3293 |
the bucket is empty, then `b.cbegin(n) == b.cend(n)`.
|
| 3294 |
|
| 3295 |
*Complexity:* Constant.
|
|
@@ -3298,11 +3332,11 @@ the bucket is empty, then `b.cbegin(n) == b.cend(n)`.
|
|
| 3298 |
b.cend(n)
|
| 3299 |
```
|
| 3300 |
|
| 3301 |
*Result:* `const_local_iterator`
|
| 3302 |
|
| 3303 |
-
*Preconditions:* `n` is in the range
|
| 3304 |
|
| 3305 |
*Returns:* An iterator which is the past-the-end value for the bucket.
|
| 3306 |
|
| 3307 |
*Complexity:* Constant.
|
| 3308 |
|
|
@@ -3407,15 +3441,15 @@ accessing the element through such pointers and references while the
|
|
| 3407 |
element is owned by a `node_type` is undefined behavior. References and
|
| 3408 |
pointers to an element obtained while it is owned by a `node_type` are
|
| 3409 |
invalidated if the element is successfully inserted.
|
| 3410 |
|
| 3411 |
The member function templates `find`, `count`, `equal_range`,
|
| 3412 |
-
`contains`, `extract`, and `
|
| 3413 |
-
resolution unless the *qualified-id*s `Pred::is_transparent`
|
| 3414 |
-
`Hash::is_transparent` are both valid and denote types
|
| 3415 |
-
Additionally, the member function templates `extract`
|
| 3416 |
-
not participate in overload resolution if
|
| 3417 |
`is_convertible_v<K&&, iterator> || is_convertible_v<K&&, const_iterator>`
|
| 3418 |
is `true`, where `K` is the type substituted as the first template
|
| 3419 |
argument.
|
| 3420 |
|
| 3421 |
A deduction guide for an unordered associative container shall not
|
|
|
|
| 25 |
|
| 26 |
[*Note 1*: This means, for example, that a node-based container would
|
| 27 |
need to construct nodes containing aligned buffers and call `construct`
|
| 28 |
to place the element into the buffer. — *end note*]
|
| 29 |
|
| 30 |
+
### General containers <a id="container.requirements.general">[[container.requirements.general]]</a>
|
| 31 |
|
| 32 |
+
#### Introduction <a id="container.intro.reqmts">[[container.intro.reqmts]]</a>
|
| 33 |
|
| 34 |
+
In [[container.requirements.general]],
|
| 35 |
|
| 36 |
- `X` denotes a container class containing objects of type `T`,
|
| 37 |
- `a` denotes a value of type `X`,
|
| 38 |
- `b` and `c` denote values of type (possibly const) `X`,
|
| 39 |
- `i` and `j` denote values of type (possibly const) `X::iterator`,
|
|
|
|
| 50 |
template<class R, class T>
|
| 51 |
concept container-compatible-range = // exposition only
|
| 52 |
ranges::input_range<R> && convertible_to<ranges::range_reference_t<R>, T>;
|
| 53 |
```
|
| 54 |
|
| 55 |
+
#### Container requirements <a id="container.reqmts">[[container.reqmts]]</a>
|
| 56 |
|
| 57 |
A type `X` meets the *container* requirements if the following types,
|
| 58 |
statements, and expressions are well-formed and have the specified
|
| 59 |
semantics.
|
| 60 |
|
|
|
|
| 134 |
```
|
| 135 |
|
| 136 |
*Ensures:* `u` is equal to the value that `rv` had before this
|
| 137 |
construction.
|
| 138 |
|
| 139 |
+
*Complexity:* Linear for `array` and `inplace_vector` and constant for
|
| 140 |
+
all other standard containers.
|
| 141 |
|
| 142 |
``` cpp
|
| 143 |
+
t = v
|
| 144 |
```
|
| 145 |
|
| 146 |
*Result:* `X&`.
|
| 147 |
|
| 148 |
*Ensures:* `t == v`.
|
|
|
|
| 255 |
|
| 256 |
*Result:* `void`.
|
| 257 |
|
| 258 |
*Effects:* Exchanges the contents of `t` and `s`.
|
| 259 |
|
| 260 |
+
*Complexity:* Linear for `array` and `inplace_vector`, and constant for
|
| 261 |
+
all other standard containers.
|
| 262 |
|
| 263 |
``` cpp
|
| 264 |
swap(t, s)
|
| 265 |
```
|
| 266 |
|
|
|
|
| 342 |
[*Note 2*: If an invocation of a constructor uses the default value of
|
| 343 |
an optional allocator argument, then the allocator type must support
|
| 344 |
value-initialization. — *end note*]
|
| 345 |
|
| 346 |
A copy of this allocator is used for any memory allocation and element
|
| 347 |
+
construction performed, by these constructors and by all other member
|
| 348 |
functions, during the lifetime of each container object or until the
|
| 349 |
allocator is replaced. The allocator may be replaced only via assignment
|
| 350 |
or `swap()`. Allocator replacement is performed by copy assignment, move
|
| 351 |
assignment, or swapping of the allocator only if
|
| 352 |
|
|
|
|
| 360 |
`get_allocator()` returns a copy of the allocator used to construct the
|
| 361 |
container or, if that allocator has been replaced, a copy of the most
|
| 362 |
recent replacement.
|
| 363 |
|
| 364 |
The expression `a.swap(b)`, for containers `a` and `b` of a standard
|
| 365 |
+
container type other than `array` and `inplace_vector`, shall exchange
|
| 366 |
+
the values of `a` and `b` without invoking any move, copy, or swap
|
| 367 |
+
operations on the individual container elements. Any `Compare`, `Pred`,
|
| 368 |
+
or `Hash` types belonging to `a` and `b` shall meet the *Cpp17Swappable*
|
| 369 |
+
requirements and shall be exchanged by calling `swap` as described in
|
| 370 |
[[swappable.requirements]]. If
|
| 371 |
`allocator_traits<allocator_type>::propagate_on_container_swap::value`
|
| 372 |
is `true`, then `allocator_type` shall meet the *Cpp17Swappable*
|
| 373 |
requirements and the allocators of `a` and `b` shall also be exchanged
|
| 374 |
by calling `swap` as described in [[swappable.requirements]].
|
|
|
|
| 378 |
refer to the same element in the other container after the swap. It is
|
| 379 |
unspecified whether an iterator with value `a.end()` before the swap
|
| 380 |
will have value `b.end()` after the swap.
|
| 381 |
|
| 382 |
Unless otherwise specified (see [[associative.reqmts.except]],
|
| 383 |
+
[[unord.req.except]], [[deque.modifiers]], [[inplace.vector.modifiers]],
|
| 384 |
+
and [[vector.modifiers]]) all container types defined in this Clause
|
| 385 |
+
meet the following additional requirements:
|
| 386 |
|
| 387 |
- If an exception is thrown by an `insert()` or `emplace()` function
|
| 388 |
while inserting a single element, that function has no effects.
|
| 389 |
- If an exception is thrown by a `push_back()`, `push_front()`,
|
| 390 |
`emplace_back()`, or `emplace_front()` function, that function has no
|
|
|
|
| 500 |
a <=> b
|
| 501 |
```
|
| 502 |
|
| 503 |
*Result:* *`synth-three-way-result`*`<X::value_type>`.
|
| 504 |
|
| 505 |
+
*Preconditions:* Either `T` models `three_way_comparable`, or `<` is
|
| 506 |
+
defined for values of type (possibly const) `T` and `<` is a total
|
| 507 |
+
ordering relationship.
|
| 508 |
|
| 509 |
*Returns:*
|
| 510 |
`lexicographical_compare_three_way(a.begin(), a.end(), b.begin(), b.end(), `*`synth-three-way`*`)`
|
| 511 |
|
| 512 |
[*Note 1*: The algorithm `lexicographical_compare_three_way` is defined
|
|
|
|
| 514 |
|
| 515 |
*Complexity:* Linear.
|
| 516 |
|
| 517 |
#### Allocator-aware containers <a id="container.alloc.reqmts">[[container.alloc.reqmts]]</a>
|
| 518 |
|
| 519 |
+
Except for `array` and `inplace_vector`, all of the containers defined
|
| 520 |
+
in [[containers]], [[stacktrace.basic]], [[basic.string]], and
|
| 521 |
+
[[re.results]] meet the additional requirements of an
|
| 522 |
*allocator-aware container*, as described below.
|
| 523 |
|
| 524 |
Given an allocator type `A` and given a container type `X` having a
|
| 525 |
`value_type` identical to `T` and an `allocator_type` identical to
|
| 526 |
`allocator_traits<A>::rebind_alloc<T>` and given an lvalue `m` of type
|
| 527 |
+
`A`, a pointer `p` of type `T*`, an expression `v` that denotes an
|
| 528 |
+
lvalue of type `T` or `const T` or an rvalue of type `const T`, and an
|
| 529 |
+
rvalue `rv` of type `T`, the following terms are defined. If `X` is not
|
| 530 |
+
allocator-aware or is a specialization of `basic_string`, the terms
|
| 531 |
+
below are defined as if `A` were `allocator<T>` — no allocator object
|
| 532 |
+
needs to be created and user specializations of `allocator<T>` are not
|
| 533 |
+
instantiated:
|
| 534 |
|
| 535 |
- `T` is **Cpp17DefaultInsertable* into `X`* means that the following
|
| 536 |
expression is well-formed:
|
| 537 |
``` cpp
|
| 538 |
allocator_traits<A>::construct(m, p)
|
|
|
|
| 553 |
|
| 554 |
and its evaluation causes the following postcondition to hold: The
|
| 555 |
value of `*p` is equivalent to the value of `rv` before the
|
| 556 |
evaluation.
|
| 557 |
\[*Note 1*: `rv` remains a valid object. Its state is
|
| 558 |
+
unspecified. — *end note*]
|
| 559 |
- `T` is **Cpp17CopyInsertable* into `X`* means that, in addition to `T`
|
| 560 |
being *Cpp17MoveInsertable* into `X`, the following expression is
|
| 561 |
well-formed:
|
| 562 |
``` cpp
|
| 563 |
allocator_traits<A>::construct(m, p, v)
|
|
|
|
| 637 |
X u(t, m);
|
| 638 |
```
|
| 639 |
|
| 640 |
*Preconditions:* `T` is *Cpp17CopyInsertable* into `X`.
|
| 641 |
|
| 642 |
+
*Ensures:* `u == t`, `u.get_allocator() == m`.
|
| 643 |
|
| 644 |
*Complexity:* Linear.
|
| 645 |
|
| 646 |
``` cpp
|
| 647 |
X u(rv);
|
|
|
|
| 727 |
`y[1] = true`. — *end note*]
|
| 728 |
|
| 729 |
### Sequence containers <a id="sequence.reqmts">[[sequence.reqmts]]</a>
|
| 730 |
|
| 731 |
A sequence container organizes a finite set of objects, all of the same
|
| 732 |
+
type, into a strictly linear arrangement. The library provides the
|
| 733 |
+
following basic kinds of sequence containers: `vector`,
|
| 734 |
+
`inplace_vector`, `forward_list`, `list`, and `deque`. In addition,
|
| 735 |
+
`array` and `hive` are provided as sequence containers which provide
|
| 736 |
+
limited sequence operations, in `array`’s case because it has a fixed
|
| 737 |
+
number of elements, and in `hive`’s case because insertion order is
|
| 738 |
+
unspecified. The library also provides container adaptors that make it
|
| 739 |
easy to construct abstract data types, such as `stack`s, `queue`s,
|
| 740 |
`flat_map`s, `flat_multimap`s, `flat_set`s, or `flat_multiset`s, out of
|
| 741 |
the basic sequence container kinds (or out of other program-defined
|
| 742 |
sequence containers).
|
| 743 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 744 |
In this subclause,
|
| 745 |
|
| 746 |
- `X` denotes a sequence container class,
|
| 747 |
- `a` denotes a value of type `X` containing elements of type `T`,
|
| 748 |
- `u` denotes the name of a variable being declared,
|
|
|
|
| 750 |
`X::allocator_type` is valid and denotes a type [[temp.deduct]] and
|
| 751 |
`allocator<T>` if it doesn’t,
|
| 752 |
- `i` and `j` denote iterators that meet the *Cpp17InputIterator*
|
| 753 |
requirements and refer to elements implicitly convertible to
|
| 754 |
`value_type`,
|
| 755 |
+
- \[`i`, `j`) denotes a valid range,
|
| 756 |
- `rg` denotes a value of a type `R` that models
|
| 757 |
`container-compatible-range<T>`,
|
| 758 |
- `il` designates an object of type `initializer_list<value_type>`,
|
| 759 |
- `n` denotes a value of type `X::size_type`,
|
| 760 |
- `p` denotes a valid constant iterator to `a`,
|
| 761 |
- `q` denotes a valid dereferenceable constant iterator to `a`,
|
| 762 |
+
- \[`q1`, `q2`) denotes a valid range of constant iterators in `a`,
|
| 763 |
- `t` denotes an lvalue or a const rvalue of `X::value_type`, and
|
| 764 |
- `rv` denotes a non-const rvalue of `X::value_type`.
|
| 765 |
- `Args` denotes a template parameter pack;
|
| 766 |
- `args` denotes a function parameter pack with the pattern `Args&&`.
|
| 767 |
|
|
|
|
| 788 |
*Preconditions:* `T` is *Cpp17EmplaceConstructible* into `X` from `*i`.
|
| 789 |
For `vector`, if the iterator does not meet the *Cpp17ForwardIterator*
|
| 790 |
requirements [[forward.iterators]], `T` is also *Cpp17MoveInsertable*
|
| 791 |
into `X`.
|
| 792 |
|
| 793 |
+
*Effects:* Constructs a sequence container equal to the range \[`i`,
|
| 794 |
+
`j`). Each iterator in the range \[`i`, `j`) is dereferenced exactly
|
| 795 |
+
once.
|
| 796 |
|
| 797 |
*Ensures:* `distance(u.begin(), u.end()) == distance(i, j)` is `true`.
|
| 798 |
|
| 799 |
``` cpp
|
| 800 |
X(from_range, rg)
|
| 801 |
```
|
| 802 |
|
| 803 |
*Preconditions:* `T` is *Cpp17EmplaceConstructible* into `X` from
|
| 804 |
+
`*ranges::begin(rg)`. For `vector`, if `R` models
|
| 805 |
+
`ranges::approximately_sized_range` but not `ranges::sized_range` or
|
| 806 |
+
models `ranges::input_range` but not `ranges::forward_range`, `T` is
|
| 807 |
+
also *Cpp17MoveInsertable* into `X`.
|
| 808 |
|
| 809 |
*Effects:* Constructs a sequence container equal to the range `rg`. Each
|
| 810 |
iterator in the range `rg` is dereferenced exactly once.
|
| 811 |
|
| 812 |
+
*Recommended practice:* If `R` models
|
| 813 |
+
`ranges::approximately_sized_range` and
|
| 814 |
+
`ranges::distance(rg) <= ranges::reserve_hint(rg)` is `true`, an
|
| 815 |
+
implementation should not perform more than a single reallocation.
|
| 816 |
+
|
| 817 |
*Ensures:* `distance(begin(), end()) == ranges::distance(rg)` is `true`.
|
| 818 |
|
| 819 |
``` cpp
|
| 820 |
X(il)
|
| 821 |
```
|
|
|
|
| 841 |
```
|
| 842 |
|
| 843 |
*Result:* `iterator`.
|
| 844 |
|
| 845 |
*Preconditions:* `T` is *Cpp17EmplaceConstructible* into `X` from
|
| 846 |
+
`args`. For `vector`, `inplace_vector`, and `deque`, `T` is also
|
| 847 |
+
*Cpp17MoveInsertable* into `X` and *Cpp17MoveAssignable*.
|
| 848 |
|
| 849 |
*Effects:* Inserts an object of type `T` constructed with
|
| 850 |
`std::forward<Args>(args)...` before `p`.
|
| 851 |
|
| 852 |
[*Note 1*: `args` can directly or indirectly refer to a value in
|
| 853 |
`a`. — *end note*]
|
| 854 |
|
| 855 |
+
*Returns:* An iterator that points to the new element.
|
|
|
|
| 856 |
|
| 857 |
``` cpp
|
| 858 |
a.insert(p, t)
|
| 859 |
```
|
| 860 |
|
| 861 |
*Result:* `iterator`.
|
| 862 |
|
| 863 |
+
*Preconditions:* `T` is *Cpp17CopyInsertable* into `X`. For `vector`,
|
| 864 |
+
`inplace_vector`, and `deque`, `T` is also *Cpp17CopyAssignable*.
|
| 865 |
|
| 866 |
*Effects:* Inserts a copy of `t` before `p`.
|
| 867 |
|
| 868 |
*Returns:* An iterator that points to the copy of `t` inserted into `a`.
|
| 869 |
|
|
|
|
| 871 |
a.insert(p, rv)
|
| 872 |
```
|
| 873 |
|
| 874 |
*Result:* `iterator`.
|
| 875 |
|
| 876 |
+
*Preconditions:* `T` is *Cpp17MoveInsertable* into `X`. For `vector`,
|
| 877 |
+
`inplace_vector`, and `deque`, `T` is also *Cpp17MoveAssignable*.
|
| 878 |
|
| 879 |
*Effects:* Inserts a copy of `rv` before `p`.
|
| 880 |
|
| 881 |
*Returns:* An iterator that points to the copy of `rv` inserted into
|
| 882 |
`a`.
|
|
|
|
| 900 |
```
|
| 901 |
|
| 902 |
*Result:* `iterator`.
|
| 903 |
|
| 904 |
*Preconditions:* `T` is *Cpp17EmplaceConstructible* into `X` from `*i`.
|
| 905 |
+
For `vector`, `inplace_vector`, and `deque`, `T` is also
|
| 906 |
+
*Cpp17MoveInsertable* into `X`, and `T` meets the
|
| 907 |
+
*Cpp17MoveConstructible*, *Cpp17MoveAssignable*, and
|
| 908 |
*Cpp17Swappable*[[swappable.requirements]] requirements. Neither `i` nor
|
| 909 |
`j` are iterators into `a`.
|
| 910 |
|
| 911 |
+
*Effects:* Inserts copies of elements in \[`i`, `j`) before `p`. Each
|
| 912 |
iterator in the range \[`i`, `j`) shall be dereferenced exactly once.
|
| 913 |
|
| 914 |
*Returns:* An iterator that points to the copy of the first element
|
| 915 |
inserted into `a`, or `p` if `i == j`.
|
| 916 |
|
|
|
|
| 919 |
```
|
| 920 |
|
| 921 |
*Result:* `iterator`.
|
| 922 |
|
| 923 |
*Preconditions:* `T` is *Cpp17EmplaceConstructible* into `X` from
|
| 924 |
+
`*ranges::begin(rg)`. For `vector`, `inplace_vector`, and `deque`, `T`
|
| 925 |
+
is also *Cpp17MoveInsertable* into `X`, and `T` meets the
|
| 926 |
*Cpp17MoveConstructible*, *Cpp17MoveAssignable*, and
|
| 927 |
*Cpp17Swappable*[[swappable.requirements]] requirements. `rg` and `a` do
|
| 928 |
not overlap.
|
| 929 |
|
| 930 |
*Effects:* Inserts copies of elements in `rg` before `p`. Each iterator
|
|
|
|
| 943 |
a.erase(q)
|
| 944 |
```
|
| 945 |
|
| 946 |
*Result:* `iterator`.
|
| 947 |
|
| 948 |
+
*Preconditions:* For `vector`, `inplace_vector`, and `deque`, `T` is
|
| 949 |
+
*Cpp17MoveAssignable*.
|
| 950 |
|
| 951 |
*Effects:* Erases the element pointed to by `q`.
|
| 952 |
|
| 953 |
*Returns:* An iterator that points to the element immediately following
|
| 954 |
`q` prior to the element being erased. If no such element exists,
|
|
|
|
| 958 |
a.erase(q1, q2)
|
| 959 |
```
|
| 960 |
|
| 961 |
*Result:* `iterator`.
|
| 962 |
|
| 963 |
+
*Preconditions:* For `vector`, `inplace_vector`, and `deque`, `T` is
|
| 964 |
+
*Cpp17MoveAssignable*.
|
| 965 |
|
| 966 |
+
*Effects:* Erases the elements in the range \[`q1`, `q2`).
|
| 967 |
|
| 968 |
*Returns:* An iterator that points to the element pointed to by `q2`
|
| 969 |
prior to any elements being erased. If no such element exists, `a.end()`
|
| 970 |
is returned.
|
| 971 |
|
|
|
|
| 993 |
and assignable from `*i`. For `vector`, if the iterator does not meet
|
| 994 |
the forward iterator requirements [[forward.iterators]], `T` is also
|
| 995 |
*Cpp17MoveInsertable* into `X`. Neither `i` nor `j` are iterators into
|
| 996 |
`a`.
|
| 997 |
|
| 998 |
+
*Effects:* Replaces elements in `a` with a copy of \[`i`, `j`).
|
| 999 |
+
Invalidates all references, pointers and iterators referring to the
|
| 1000 |
+
elements of `a`. For `vector` and `deque`, also invalidates the
|
| 1001 |
+
past-the-end iterator. Each iterator in the range \[`i`, `j`) is
|
| 1002 |
+
dereferenced exactly once.
|
| 1003 |
|
| 1004 |
``` cpp
|
| 1005 |
a.assign_range(rg)
|
| 1006 |
```
|
| 1007 |
|
|
|
|
| 1009 |
|
| 1010 |
*Mandates:* `assignable_from<T&, ranges::range_reference_t<R>>` is
|
| 1011 |
modeled.
|
| 1012 |
|
| 1013 |
*Preconditions:* `T` is *Cpp17EmplaceConstructible* into `X` from
|
| 1014 |
+
`*ranges::begin(rg)`. For `vector`, if `R` models
|
| 1015 |
+
`ranges::approximately_sized_range` but not `ranges::sized_range` or
|
| 1016 |
+
models `ranges::input_range` but not `ranges::forward_range`, `T` is
|
| 1017 |
+
also *Cpp17MoveInsertable* into `X`. `rg` and `a` do not overlap.
|
| 1018 |
|
| 1019 |
*Effects:* Replaces elements in `a` with a copy of each element in `rg`.
|
| 1020 |
Invalidates all references, pointers, and iterators referring to the
|
| 1021 |
elements of `a`. For `vector` and `deque`, also invalidates the
|
| 1022 |
past-the-end iterator. Each iterator in the range `rg` is dereferenced
|
| 1023 |
exactly once.
|
| 1024 |
|
| 1025 |
+
*Recommended practice:* If `R` models
|
| 1026 |
+
`ranges::approximately_sized_range` and
|
| 1027 |
+
`ranges::distance(rg) <= ranges::reserve_hint(rg)` is `true`, an
|
| 1028 |
+
implementation should not perform any reallocation.
|
| 1029 |
+
|
| 1030 |
``` cpp
|
| 1031 |
a.assign(il)
|
| 1032 |
```
|
| 1033 |
|
| 1034 |
*Effects:* Equivalent to `a.assign(il.begin(), il.end())`.
|
|
|
|
| 1090 |
a.front()
|
| 1091 |
```
|
| 1092 |
|
| 1093 |
*Result:* `reference; const_reference` for constant `a`.
|
| 1094 |
|
| 1095 |
+
`a.empty()` is `false`.
|
| 1096 |
+
|
| 1097 |
*Returns:* `*a.begin()`
|
| 1098 |
|
| 1099 |
*Remarks:* Required for `basic_string`, `array`, `deque`,
|
| 1100 |
+
`forward_list`, `inplace_vector`, `list`, and `vector`.
|
| 1101 |
|
| 1102 |
``` cpp
|
| 1103 |
a.back()
|
| 1104 |
```
|
| 1105 |
|
| 1106 |
*Result:* `reference; const_reference` for constant `a`.
|
| 1107 |
|
| 1108 |
+
`a.empty()` is `false`.
|
| 1109 |
+
|
| 1110 |
*Effects:* Equivalent to:
|
| 1111 |
|
| 1112 |
``` cpp
|
| 1113 |
auto tmp = a.end();
|
| 1114 |
--tmp;
|
| 1115 |
return *tmp;
|
| 1116 |
```
|
| 1117 |
|
| 1118 |
+
*Remarks:* Required for `basic_string`, `array`, `deque`,
|
| 1119 |
+
`inplace_vector`, `list`, and `vector`.
|
| 1120 |
|
| 1121 |
``` cpp
|
| 1122 |
a.emplace_front(args)
|
| 1123 |
```
|
| 1124 |
|
|
|
|
| 1146 |
*Effects:* Appends an object of type `T` constructed with
|
| 1147 |
`std::forward<Args>(args)...`.
|
| 1148 |
|
| 1149 |
*Returns:* `a.back()`.
|
| 1150 |
|
| 1151 |
+
*Remarks:* Required for `deque`, `inplace_vector`, `list`, and `vector`.
|
| 1152 |
|
| 1153 |
``` cpp
|
| 1154 |
a.push_front(t)
|
| 1155 |
```
|
| 1156 |
|
|
|
|
| 1202 |
|
| 1203 |
*Preconditions:* `T` is *Cpp17CopyInsertable* into `X`.
|
| 1204 |
|
| 1205 |
*Effects:* Appends a copy of `t`.
|
| 1206 |
|
| 1207 |
+
*Remarks:* Required for `basic_string`, `deque`, `inplace_vector`,
|
| 1208 |
+
`list`, and `vector`.
|
| 1209 |
|
| 1210 |
``` cpp
|
| 1211 |
a.push_back(rv)
|
| 1212 |
```
|
| 1213 |
|
|
|
|
| 1215 |
|
| 1216 |
*Preconditions:* `T` is *Cpp17MoveInsertable* into `X`.
|
| 1217 |
|
| 1218 |
*Effects:* Appends a copy of `rv`.
|
| 1219 |
|
| 1220 |
+
*Remarks:* Required for `basic_string`, `deque`, `inplace_vector`,
|
| 1221 |
+
`list`, and `vector`.
|
| 1222 |
|
| 1223 |
``` cpp
|
| 1224 |
a.append_range(rg)
|
| 1225 |
```
|
| 1226 |
|
|
|
|
| 1231 |
into `X`.
|
| 1232 |
|
| 1233 |
*Effects:* Inserts copies of elements in `rg` before `end()`. Each
|
| 1234 |
iterator in the range `rg` is dereferenced exactly once.
|
| 1235 |
|
| 1236 |
+
*Remarks:* Required for `deque`, `inplace_vector`, `list`, and `vector`.
|
| 1237 |
|
| 1238 |
``` cpp
|
| 1239 |
a.pop_front()
|
| 1240 |
```
|
| 1241 |
|
| 1242 |
*Result:* `void`
|
| 1243 |
|
| 1244 |
+
`a.empty()` is `false`.
|
| 1245 |
|
| 1246 |
*Effects:* Destroys the first element.
|
| 1247 |
|
| 1248 |
*Remarks:* Required for `deque`, `forward_list`, and `list`.
|
| 1249 |
|
|
|
|
| 1251 |
a.pop_back()
|
| 1252 |
```
|
| 1253 |
|
| 1254 |
*Result:* `void`
|
| 1255 |
|
| 1256 |
+
`a.empty()` is `false`.
|
| 1257 |
|
| 1258 |
*Effects:* Destroys the last element.
|
| 1259 |
|
| 1260 |
+
*Remarks:* Required for `basic_string`, `deque`, `inplace_vector`,
|
| 1261 |
+
`list`, and `vector`.
|
| 1262 |
|
| 1263 |
``` cpp
|
| 1264 |
a[n]
|
| 1265 |
```
|
| 1266 |
|
| 1267 |
+
*Result:* `reference; const_reference` for constant `a`.
|
| 1268 |
|
| 1269 |
+
`n < a.size()` is `true`.
|
| 1270 |
|
| 1271 |
+
*Effects:* Equivalent to: `return *(a.begin() + n);`
|
| 1272 |
+
|
| 1273 |
+
*Remarks:* Required for `basic_string`, `array`, `deque`,
|
| 1274 |
+
`inplace_vector`, and `vector`.
|
| 1275 |
|
| 1276 |
``` cpp
|
| 1277 |
a.at(n)
|
| 1278 |
```
|
| 1279 |
|
| 1280 |
+
*Result:* `reference; const_reference` for constant `a`.
|
| 1281 |
|
| 1282 |
*Returns:* `*(a.begin() + n)`
|
| 1283 |
|
| 1284 |
*Throws:* `out_of_range` if `n >= a.size()`.
|
| 1285 |
|
| 1286 |
+
*Remarks:* Required for `basic_string`, `array`, `deque`,
|
| 1287 |
+
`inplace_vector`, and `vector`.
|
| 1288 |
|
| 1289 |
### Node handles <a id="container.node">[[container.node]]</a>
|
| 1290 |
|
| 1291 |
#### Overview <a id="container.node.overview">[[container.node.overview]]</a>
|
| 1292 |
|
|
|
|
| 1332 |
using key_type = see below; // not present for set containers
|
| 1333 |
using mapped_type = see below; // not present for set containers
|
| 1334 |
using allocator_type = see below;
|
| 1335 |
|
| 1336 |
private:
|
| 1337 |
+
using container-node-type = unspecified; // exposition only
|
| 1338 |
+
using ator-traits = allocator_traits<allocator_type>; // exposition only
|
| 1339 |
|
| 1340 |
+
typename ator-traits::template
|
| 1341 |
+
rebind_traits<container-node-type>::pointer ptr_; // exposition only
|
| 1342 |
optional<allocator_type> alloc_; // exposition only
|
| 1343 |
|
| 1344 |
public:
|
| 1345 |
// [container.node.cons], constructors, copy, and assignment
|
| 1346 |
constexpr node-handle() noexcept : ptr_(), alloc_() {}
|
| 1347 |
+
constexpr node-handle(node-handle&&) noexcept;
|
| 1348 |
+
constexpr node-handle& operator=(node-handle&&);
|
| 1349 |
|
| 1350 |
// [container.node.dtor], destructor
|
| 1351 |
+
constexpr ~node-handle();
|
| 1352 |
|
| 1353 |
// [container.node.observers], observers
|
| 1354 |
+
constexpr value_type& value() const; // not present for map containers
|
| 1355 |
key_type& key() const; // not present for set containers
|
| 1356 |
+
constexpr mapped_type& mapped() const; // not present for set containers
|
| 1357 |
|
| 1358 |
+
constexpr allocator_type get_allocator() const;
|
| 1359 |
+
constexpr explicit operator bool() const noexcept;
|
| 1360 |
+
constexpr bool empty() const noexcept;
|
| 1361 |
|
| 1362 |
// [container.node.modifiers], modifiers
|
| 1363 |
+
constexpr void swap(node-handle&)
|
| 1364 |
+
noexcept(ator-traits::propagate_on_container_swap::value ||
|
| 1365 |
+
ator-traits::is_always_equal::value);
|
| 1366 |
|
| 1367 |
+
friend constexpr void swap(node-handle& x, node-handle& y) noexcept(noexcept(x.swap(y))) {
|
| 1368 |
x.swap(y);
|
| 1369 |
}
|
| 1370 |
};
|
| 1371 |
```
|
| 1372 |
|
| 1373 |
#### Constructors, copy, and assignment <a id="container.node.cons">[[container.node.cons]]</a>
|
| 1374 |
|
| 1375 |
``` cpp
|
| 1376 |
+
constexpr node-handle(node-handle&& nh) noexcept;
|
| 1377 |
```
|
| 1378 |
|
| 1379 |
+
*Effects:* Constructs a *node-handle* object initializing *ptr\_* with
|
| 1380 |
+
`nh.`*`ptr_`*. Move constructs *alloc\_* with `nh.`*`alloc_`*. Assigns
|
| 1381 |
+
`nullptr` to `nh.`*`ptr_`* and assigns `nullopt` to `nh.`*`alloc_`*.
|
| 1382 |
|
| 1383 |
``` cpp
|
| 1384 |
+
constexpr node-handle& operator=(node-handle&& nh);
|
| 1385 |
```
|
| 1386 |
|
| 1387 |
+
*Preconditions:* Either `!`*`alloc_`* is `true`, or
|
| 1388 |
+
*`ator-traits`*`::propagate_on_container_move_assignment::value` is
|
| 1389 |
+
`true`, or *`alloc_`*` == nh.`*`alloc_`* is `true`.
|
| 1390 |
|
| 1391 |
*Effects:*
|
| 1392 |
|
| 1393 |
+
- If *`ptr_`*` != nullptr` is `true`, destroys the `value_type`
|
| 1394 |
+
subobject in the *container-node-type* object pointed to by *ptr\_* by
|
| 1395 |
+
calling *`ator-traits`*`::destroy`, then deallocates *ptr\_* by
|
| 1396 |
+
calling
|
| 1397 |
+
*`ator-traits`*`::template rebind_traits<`*`container-node-type`*`>::deallocate`.
|
| 1398 |
+
- Assigns `nh.`*`ptr_`* to *ptr\_*.
|
| 1399 |
+
- If `!`*`alloc_`* is `true` or
|
| 1400 |
+
*`ator-traits`*`::propagate_on_container_move_assignment::value` is
|
| 1401 |
+
`true`, move assigns `nh.`*`alloc_`* to *alloc\_*.
|
| 1402 |
+
- Assigns `nullptr` to `nh.`*`ptr_`* and assigns `nullopt` to
|
| 1403 |
+
`nh.`*`alloc_`*.
|
| 1404 |
|
| 1405 |
*Returns:* `*this`.
|
| 1406 |
|
| 1407 |
*Throws:* Nothing.
|
| 1408 |
|
| 1409 |
#### Destructor <a id="container.node.dtor">[[container.node.dtor]]</a>
|
| 1410 |
|
| 1411 |
``` cpp
|
| 1412 |
+
constexpr ~node-handle();
|
| 1413 |
```
|
| 1414 |
|
| 1415 |
+
*Effects:* If *`ptr_`*` != nullptr` is `true`, destroys the `value_type`
|
| 1416 |
+
subobject in the *container-node-type* object pointed to by *ptr\_* by
|
| 1417 |
+
calling *`ator-traits`*`::destroy`, then deallocates *ptr\_* by calling
|
| 1418 |
+
*`ator-traits`*`::template rebind_traits<`*`container-node-type`*`>::deallocate`.
|
| 1419 |
|
| 1420 |
#### Observers <a id="container.node.observers">[[container.node.observers]]</a>
|
| 1421 |
|
| 1422 |
``` cpp
|
| 1423 |
+
constexpr value_type& value() const;
|
| 1424 |
```
|
| 1425 |
|
| 1426 |
*Preconditions:* `empty() == false`.
|
| 1427 |
|
| 1428 |
*Returns:* A reference to the `value_type` subobject in the
|
| 1429 |
+
*container-node-type* object pointed to by *ptr\_*.
|
| 1430 |
|
| 1431 |
*Throws:* Nothing.
|
| 1432 |
|
| 1433 |
``` cpp
|
| 1434 |
key_type& key() const;
|
| 1435 |
```
|
| 1436 |
|
| 1437 |
*Preconditions:* `empty() == false`.
|
| 1438 |
|
| 1439 |
*Returns:* A non-const reference to the `key_type` member of the
|
| 1440 |
+
`value_type` subobject in the *container-node-type* object pointed to by
|
| 1441 |
+
*ptr\_*.
|
| 1442 |
|
| 1443 |
*Throws:* Nothing.
|
| 1444 |
|
| 1445 |
*Remarks:* Modifying the key through the returned reference is
|
| 1446 |
permitted.
|
| 1447 |
|
| 1448 |
``` cpp
|
| 1449 |
+
constexpr mapped_type& mapped() const;
|
| 1450 |
```
|
| 1451 |
|
| 1452 |
*Preconditions:* `empty() == false`.
|
| 1453 |
|
| 1454 |
*Returns:* A reference to the `mapped_type` member of the `value_type`
|
| 1455 |
+
subobject in the *container-node-type* object pointed to by *ptr\_*.
|
| 1456 |
|
| 1457 |
*Throws:* Nothing.
|
| 1458 |
|
| 1459 |
``` cpp
|
| 1460 |
+
constexpr allocator_type get_allocator() const;
|
| 1461 |
```
|
| 1462 |
|
| 1463 |
*Preconditions:* `empty() == false`.
|
| 1464 |
|
| 1465 |
+
*Returns:* `*`*`alloc_`*.
|
| 1466 |
|
| 1467 |
*Throws:* Nothing.
|
| 1468 |
|
| 1469 |
``` cpp
|
| 1470 |
+
constexpr explicit operator bool() const noexcept;
|
| 1471 |
```
|
| 1472 |
|
| 1473 |
+
*Returns:* *`ptr_`*` != nullptr`.
|
| 1474 |
|
| 1475 |
``` cpp
|
| 1476 |
+
constexpr bool empty() const noexcept;
|
| 1477 |
```
|
| 1478 |
|
| 1479 |
+
*Returns:* *`ptr_`*` == nullptr`.
|
| 1480 |
|
| 1481 |
#### Modifiers <a id="container.node.modifiers">[[container.node.modifiers]]</a>
|
| 1482 |
|
| 1483 |
``` cpp
|
| 1484 |
+
constexpr void swap(node-handle& nh)
|
| 1485 |
+
noexcept(ator-traits::propagate_on_container_swap::value ||
|
| 1486 |
+
ator-traits::is_always_equal::value);
|
| 1487 |
```
|
| 1488 |
|
| 1489 |
+
*Preconditions:* `!`*`alloc_`* is `true`, or `!nh.`*`alloc_`*, or
|
| 1490 |
+
*`ator-traits`*`::propagate_on_container_swap::value` is `true`, or
|
| 1491 |
+
*`alloc_`*` == nh.`*`alloc_`* is `true`.
|
| 1492 |
|
| 1493 |
+
*Effects:* Calls `swap(`*`ptr_`*`, nh.`*`ptr_`*`)`. If `!`*`alloc_`* is
|
| 1494 |
+
`true`, or `!nh.`*`alloc_`* is `true`, or
|
| 1495 |
+
*`ator-traits`*`::propagate_on_container_swap::value` is `true` calls
|
| 1496 |
+
`swap(`*`alloc_`*`, nh.`*`alloc_`*`)`.
|
| 1497 |
|
| 1498 |
### Insert return type <a id="container.insert.return">[[container.insert.return]]</a>
|
| 1499 |
|
| 1500 |
The associative containers with unique keys and the unordered containers
|
| 1501 |
with unique keys have a member function `insert` that returns a nested
|
|
|
|
| 1510 |
bool inserted;
|
| 1511 |
NodeType node;
|
| 1512 |
};
|
| 1513 |
```
|
| 1514 |
|
| 1515 |
+
The name *`insert-return-type`* is for exposition only.
|
| 1516 |
*`insert-return-type`* has the template parameters, data members, and
|
| 1517 |
special members specified above. It has no base classes or members other
|
| 1518 |
than those specified.
|
| 1519 |
|
| 1520 |
### Associative containers <a id="associative.reqmts">[[associative.reqmts]]</a>
|
|
|
|
| 1573 |
|
| 1574 |
- `X` denotes an associative container class,
|
| 1575 |
- `a` denotes a value of type `X`,
|
| 1576 |
- `a2` denotes a value of a type with nodes compatible with type `X` (
|
| 1577 |
[[container.node.compat]]),
|
| 1578 |
+
- `b` denotes a value of type `X` or `const X`,
|
| 1579 |
- `u` denotes the name of a variable being declared,
|
| 1580 |
- `a_uniq` denotes a value of type `X` when `X` supports unique keys,
|
| 1581 |
+
- `a_eq` denotes a value of type `X` when `X` supports equivalent keys,
|
| 1582 |
- `a_tran` denotes a value of type `X` or `const X` when the
|
| 1583 |
*qualified-id* `X::key_compare::is_transparent` is valid and denotes a
|
| 1584 |
type [[temp.deduct]],
|
| 1585 |
- `i` and `j` meet the *Cpp17InputIterator* requirements and refer to
|
| 1586 |
elements implicitly convertible to `value_type`,
|
|
|
|
| 1588 |
- `rg` denotes a value of a type `R` that models
|
| 1589 |
`container-compatible-range<value_type>`,
|
| 1590 |
- `p` denotes a valid constant iterator to `a`,
|
| 1591 |
- `q` denotes a valid dereferenceable constant iterator to `a`,
|
| 1592 |
- `r` denotes a valid dereferenceable iterator to `a`,
|
| 1593 |
+
- \[`q1`, `q2`) denotes a valid range of constant iterators in `a`,
|
| 1594 |
- `il` designates an object of type `initializer_list<value_type>`,
|
| 1595 |
- `t` denotes a value of type `X::value_type`,
|
| 1596 |
- `k` denotes a value of type `X::key_type`, and
|
| 1597 |
- `c` denotes a value of type `X::key_compare` or
|
| 1598 |
`const X::key_compare`;
|
|
|
|
| 1614 |
- `m` denotes an allocator of a type convertible to `A`, and `nh`
|
| 1615 |
denotes a non-const rvalue of type `X::node_type`.
|
| 1616 |
|
| 1617 |
A type `X` meets the *associative container* requirements if `X` meets
|
| 1618 |
all the requirements of an allocator-aware container
|
| 1619 |
+
[[container.alloc.reqmts]] and the following types, statements, and
|
| 1620 |
+
expressions are well-formed and have the specified semantics, except
|
| 1621 |
that for `map` and `multimap`, the requirements placed on `value_type`
|
| 1622 |
+
in [[container.reqmts]] apply instead to `key_type` and `mapped_type`.
|
|
|
|
| 1623 |
|
| 1624 |
+
[*Note 3*: For example, in some cases `key_type` and `mapped_type` need
|
| 1625 |
+
to be *Cpp17CopyAssignable* even though the associated `value_type`,
|
| 1626 |
+
`pair<const key_type, mapped_type>`, is not
|
| 1627 |
*Cpp17CopyAssignable*. — *end note*]
|
| 1628 |
|
| 1629 |
``` cpp
|
| 1630 |
typename X::key_type
|
| 1631 |
```
|
|
|
|
| 1844 |
|
| 1845 |
*Effects:* Equivalent to `a.emplace(std::forward<Args>(args)...)`,
|
| 1846 |
except that the element is inserted as close as possible to the position
|
| 1847 |
just prior to `p`.
|
| 1848 |
|
| 1849 |
+
*Returns:* The iterator returned by `emplace`.
|
|
|
|
| 1850 |
|
| 1851 |
*Complexity:* Logarithmic in general, but amortized constant if the
|
| 1852 |
element is inserted right before `p`.
|
| 1853 |
|
| 1854 |
``` cpp
|
|
|
|
| 2057 |
a.merge(a2)
|
| 2058 |
```
|
| 2059 |
|
| 2060 |
*Result:* `void`
|
| 2061 |
|
| 2062 |
+
*Preconditions:* `a.get_allocator() == a2.get_allocator()` is `true`.
|
| 2063 |
|
| 2064 |
*Effects:* Attempts to extract each element in `a2` and insert it into
|
| 2065 |
`a` using the comparison object of `a`. In containers with unique keys,
|
| 2066 |
if there is an element in `a` with key equivalent to the key of an
|
| 2067 |
element from `a2`, then that element is not extracted from `a2`.
|
| 2068 |
|
| 2069 |
*Ensures:* Pointers and references to the transferred elements of `a2`
|
| 2070 |
+
refer to those same elements but as members of `a`. If `a.begin()` and
|
| 2071 |
+
`a2.begin()` have the same type, iterators referring to the transferred
|
| 2072 |
+
elements will continue to refer to their elements, but they now behave
|
| 2073 |
+
as iterators into `a`, not into `a2`.
|
| 2074 |
|
| 2075 |
*Throws:* Nothing unless the comparison object throws.
|
| 2076 |
|
| 2077 |
*Complexity:* N log(`a.size()+` N), where N has the value `a2.size()`.
|
| 2078 |
|
|
|
|
| 2244 |
*Result:* `iterator`; `const_iterator` for constant `b`.
|
| 2245 |
|
| 2246 |
*Returns:* An iterator pointing to the first element with key greater
|
| 2247 |
than `k`, or `b.end()` if such an element is not found.
|
| 2248 |
|
| 2249 |
+
*Complexity:* Logarithmic.
|
| 2250 |
|
| 2251 |
``` cpp
|
| 2252 |
a_tran.upper_bound(ku)
|
| 2253 |
```
|
| 2254 |
|
|
|
|
| 2446 |
- `a_tran` denotes a value of type `X` or `const X` when the
|
| 2447 |
*qualified-id*s `X::key_equal::is_transparent` and
|
| 2448 |
`X::hasher::is_transparent` are both valid and denote types
|
| 2449 |
[[temp.deduct]],
|
| 2450 |
- `i` and `j` denote input iterators that refer to `value_type`,
|
| 2451 |
+
- \[`i`, `j`) denotes a valid range,
|
| 2452 |
- `rg` denotes a value of a type `R` that models
|
| 2453 |
`container-compatible-range<value_type>`,
|
| 2454 |
- `p` and `q2` denote valid constant iterators to `a`,
|
| 2455 |
- `q` and `q1` denote valid dereferenceable constant iterators to `a`,
|
| 2456 |
- `r` denotes a valid dereferenceable iterator to `a`,
|
| 2457 |
+
- \[`q1`, `q2`) denotes a valid range in `a`,
|
| 2458 |
- `il` denotes a value of type `initializer_list<value_type>`,
|
| 2459 |
- `t` denotes a value of type `X::value_type`,
|
| 2460 |
- `k` denotes a value of type `key_type`,
|
| 2461 |
- `hf` denotes a value of type `hasher` or `const hasher`,
|
| 2462 |
- `eq` denotes a value of type `key_equal` or `const key_equal`,
|
|
|
|
| 2479 |
- `z` denotes a value of type `float`, and
|
| 2480 |
- `nh` denotes an rvalue of type `X::node_type`.
|
| 2481 |
|
| 2482 |
A type `X` meets the *unordered associative container* requirements if
|
| 2483 |
`X` meets all the requirements of an allocator-aware container
|
| 2484 |
+
[[container.alloc.reqmts]] and the following types, statements, and
|
| 2485 |
+
expressions are well-formed and have the specified semantics, except
|
| 2486 |
that for `unordered_map` and `unordered_multimap`, the requirements
|
| 2487 |
+
placed on `value_type` in [[container.reqmts]] apply instead to
|
| 2488 |
`key_type` and `mapped_type`.
|
| 2489 |
|
| 2490 |
+
[*Note 3*: For example, `key_type` and `mapped_type` sometimes need to
|
| 2491 |
+
be *Cpp17CopyAssignable* even though the associated `value_type`,
|
| 2492 |
+
`pair<const key_type, mapped_type>`, is not
|
| 2493 |
*Cpp17CopyAssignable*. — *end note*]
|
| 2494 |
|
| 2495 |
``` cpp
|
| 2496 |
typename X::key_type
|
| 2497 |
```
|
|
|
|
| 2758 |
``` cpp
|
| 2759 |
X(b)
|
| 2760 |
```
|
| 2761 |
|
| 2762 |
*Effects:* In addition to the container
|
| 2763 |
+
requirements [[container.reqmts]], copies the hash function, predicate,
|
| 2764 |
+
and maximum load factor.
|
| 2765 |
|
| 2766 |
*Complexity:* Average case linear in `b.size()`, worst case quadratic.
|
| 2767 |
|
| 2768 |
``` cpp
|
| 2769 |
a = b
|
|
|
|
| 2849 |
a.emplace_hint(p, args)
|
| 2850 |
```
|
| 2851 |
|
| 2852 |
*Result:* `iterator`
|
| 2853 |
|
| 2854 |
+
*Effects:* Equivalent to `a.emplace(std::forward<Args>(args)...)`,
|
| 2855 |
+
except that the `const_iterator` `p` is a hint pointing to where the
|
| 2856 |
+
search should start. Implementations are permitted to ignore the hint.
|
| 2857 |
|
| 2858 |
+
*Returns:* The iterator returned by `emplace`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2859 |
|
| 2860 |
``` cpp
|
| 2861 |
a_uniq.insert(t)
|
| 2862 |
```
|
| 2863 |
|
|
|
|
| 2918 |
*Result:* `void`
|
| 2919 |
|
| 2920 |
*Preconditions:* `value_type` is *Cpp17EmplaceConstructible* into `X`
|
| 2921 |
from `*i`. Neither `i` nor `j` are iterators into `a`.
|
| 2922 |
|
| 2923 |
+
*Effects:* Equivalent to `a.insert(t)` for each element in \[`i`, `j`).
|
| 2924 |
|
| 2925 |
*Complexity:* Average case 𝑂(N), where N is `distance(i, j)`, worst case
|
| 2926 |
𝑂(N(`a.size()` + 1)).
|
| 2927 |
|
| 2928 |
``` cpp
|
|
|
|
| 3124 |
a.erase(q1, q2)
|
| 3125 |
```
|
| 3126 |
|
| 3127 |
*Result:* `iterator`
|
| 3128 |
|
| 3129 |
+
*Effects:* Erases all elements in the range \[`q1`, `q2`).
|
| 3130 |
|
| 3131 |
*Returns:* The iterator immediately following the erased elements prior
|
| 3132 |
to the erasure.
|
| 3133 |
|
| 3134 |
*Complexity:* Average case linear in `distance(q1, q2)`, worst case
|
|
|
|
| 3256 |
|
| 3257 |
*Preconditions:* `b.bucket_count() > 0`.
|
| 3258 |
|
| 3259 |
*Returns:* The index of the bucket in which elements with keys
|
| 3260 |
equivalent to `k` would be found, if any such element existed. The
|
| 3261 |
+
return value is in the range \[`0`, `b.bucket_count()`).
|
| 3262 |
+
|
| 3263 |
+
*Complexity:* Constant.
|
| 3264 |
+
|
| 3265 |
+
``` cpp
|
| 3266 |
+
a_tran.bucket(ke)
|
| 3267 |
+
```
|
| 3268 |
+
|
| 3269 |
+
*Result:* `size_type`
|
| 3270 |
+
|
| 3271 |
+
*Preconditions:* `a_tran.bucket_count() > 0`.
|
| 3272 |
+
|
| 3273 |
+
*Ensures:* The return value is in the range \[`0`,
|
| 3274 |
+
`a_tran.bucket_count()`).
|
| 3275 |
+
|
| 3276 |
+
*Returns:* The index of the bucket in which elements with keys
|
| 3277 |
+
equivalent to `ke` would be found, if any such element existed.
|
| 3278 |
|
| 3279 |
*Complexity:* Constant.
|
| 3280 |
|
| 3281 |
``` cpp
|
| 3282 |
b.bucket_size(n)
|
| 3283 |
```
|
| 3284 |
|
| 3285 |
*Result:* `size_type`
|
| 3286 |
|
| 3287 |
+
*Preconditions:* `n` shall be in the range \[`0`, `b.bucket_count()`).
|
| 3288 |
|
| 3289 |
*Returns:* The number of elements in the `n`ᵗʰ bucket.
|
| 3290 |
|
| 3291 |
*Complexity:* 𝑂(`b.bucket_size(n)`)
|
| 3292 |
|
|
|
|
| 3294 |
b.begin(n)
|
| 3295 |
```
|
| 3296 |
|
| 3297 |
*Result:* `local_iterator`; `const_local_iterator` for constant `b`.
|
| 3298 |
|
| 3299 |
+
*Preconditions:* `n` is in the range \[`0`, `b.bucket_count()`).
|
| 3300 |
|
| 3301 |
*Returns:* An iterator referring to the first element in the bucket. If
|
| 3302 |
the bucket is empty, then `b.begin(n) == b.end(n)`.
|
| 3303 |
|
| 3304 |
*Complexity:* Constant.
|
|
|
|
| 3307 |
b.end(n)
|
| 3308 |
```
|
| 3309 |
|
| 3310 |
*Result:* `local_iterator`; `const_local_iterator` for constant `b`.
|
| 3311 |
|
| 3312 |
+
*Preconditions:* `n` is in the range \[`0`, `b.bucket_count()`).
|
| 3313 |
|
| 3314 |
*Returns:* An iterator which is the past-the-end value for the bucket.
|
| 3315 |
|
| 3316 |
*Complexity:* Constant.
|
| 3317 |
|
|
|
|
| 3319 |
b.cbegin(n)
|
| 3320 |
```
|
| 3321 |
|
| 3322 |
*Result:* `const_local_iterator`
|
| 3323 |
|
| 3324 |
+
*Preconditions:* `n` shall be in the range \[`0`, `b.bucket_count()`).
|
| 3325 |
|
| 3326 |
*Returns:* An iterator referring to the first element in the bucket. If
|
| 3327 |
the bucket is empty, then `b.cbegin(n) == b.cend(n)`.
|
| 3328 |
|
| 3329 |
*Complexity:* Constant.
|
|
|
|
| 3332 |
b.cend(n)
|
| 3333 |
```
|
| 3334 |
|
| 3335 |
*Result:* `const_local_iterator`
|
| 3336 |
|
| 3337 |
+
*Preconditions:* `n` is in the range \[`0`, `b.bucket_count()`).
|
| 3338 |
|
| 3339 |
*Returns:* An iterator which is the past-the-end value for the bucket.
|
| 3340 |
|
| 3341 |
*Complexity:* Constant.
|
| 3342 |
|
|
|
|
| 3441 |
element is owned by a `node_type` is undefined behavior. References and
|
| 3442 |
pointers to an element obtained while it is owned by a `node_type` are
|
| 3443 |
invalidated if the element is successfully inserted.
|
| 3444 |
|
| 3445 |
The member function templates `find`, `count`, `equal_range`,
|
| 3446 |
+
`contains`, `extract`, `erase`, and `bucket` shall not participate in
|
| 3447 |
+
overload resolution unless the *qualified-id*s `Pred::is_transparent`
|
| 3448 |
+
and `Hash::is_transparent` are both valid and denote types
|
| 3449 |
+
[[temp.deduct]]. Additionally, the member function templates `extract`
|
| 3450 |
+
and `erase` shall not participate in overload resolution if
|
| 3451 |
`is_convertible_v<K&&, iterator> || is_convertible_v<K&&, const_iterator>`
|
| 3452 |
is `true`, where `K` is the type substituted as the first template
|
| 3453 |
argument.
|
| 3454 |
|
| 3455 |
A deduction guide for an unordered associative container shall not
|