- tmp/tmpltiy_cjy/{from.md → to.md} +476 -51
tmp/tmpltiy_cjy/{from.md → to.md}
RENAMED
|
@@ -4,72 +4,312 @@ A sequence container organizes a finite set of objects, all of the same
|
|
| 4 |
type, into a strictly linear arrangement. The library provides four
|
| 5 |
basic kinds of sequence containers: `vector`, `forward_list`, `list`,
|
| 6 |
and `deque`. In addition, `array` is provided as a sequence container
|
| 7 |
which provides limited sequence operations because it has a fixed number
|
| 8 |
of elements. The library also provides container adaptors that make it
|
| 9 |
-
easy to construct abstract data types, such as `stack`s
|
| 10 |
-
|
| 11 |
-
|
|
|
|
| 12 |
|
| 13 |
[*Note 1*: The sequence containers offer the programmer different
|
| 14 |
-
complexity trade-offs
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
deletions take place at the beginning or at the end of the sequence.
|
| 21 |
-
When choosing a container, remember `vector` is best; leave a comment to
|
| 22 |
explain if you choose from the rest! — *end note*]
|
| 23 |
|
| 24 |
-
In
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
|
|
|
|
|
|
| 28 |
`X::allocator_type` is valid and denotes a type [[temp.deduct]] and
|
| 29 |
-
`allocator<T>` if it doesn’t,
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
`
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
The complexities of the expressions are sequence dependent.
|
| 42 |
|
| 43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
`a`. — *end note*]
|
| 45 |
|
| 46 |
-
|
| 47 |
-
|
| 48 |
|
| 49 |
-
|
| 50 |
-
|
|
|
|
| 51 |
|
| 52 |
-
|
| 53 |
-
first element inserted into `a`, or `p` if `n == 0`.
|
| 54 |
|
| 55 |
-
|
| 56 |
-
|
| 57 |
|
| 58 |
-
|
| 59 |
-
first element inserted into `a`, or `p` if `il` is empty.
|
| 60 |
|
| 61 |
-
|
| 62 |
-
element constructed from `args` into `a`.
|
| 63 |
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
|
| 72 |
For every sequence container defined in this Clause and in [[strings]]:
|
| 73 |
|
| 74 |
- If the constructor
|
| 75 |
``` cpp
|
|
@@ -103,13 +343,198 @@ For every sequence container defined in this Clause and in [[strings]]:
|
|
| 103 |
and a type that does not qualify as an input iterator is deduced for
|
| 104 |
that parameter, or if it has an `Allocator` template parameter and a
|
| 105 |
type that does not qualify as an allocator is deduced for that
|
| 106 |
parameter.
|
| 107 |
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
column, and shall implement them so as to take amortized constant time.
|
| 112 |
|
| 113 |
-
|
| 114 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
|
|
|
|
| 4 |
type, into a strictly linear arrangement. The library provides four
|
| 5 |
basic kinds of sequence containers: `vector`, `forward_list`, `list`,
|
| 6 |
and `deque`. In addition, `array` is provided as a sequence container
|
| 7 |
which provides limited sequence operations because it has a fixed number
|
| 8 |
of elements. The library also provides container adaptors that make it
|
| 9 |
+
easy to construct abstract data types, such as `stack`s, `queue`s,
|
| 10 |
+
`flat_map`s, `flat_multimap`s, `flat_set`s, or `flat_multiset`s, out of
|
| 11 |
+
the basic sequence container kinds (or out of other program-defined
|
| 12 |
+
sequence containers).
|
| 13 |
|
| 14 |
[*Note 1*: The sequence containers offer the programmer different
|
| 15 |
+
complexity trade-offs. `vector` is appropriate in most circumstances.
|
| 16 |
+
`array` has a fixed size known during translation. `list` or
|
| 17 |
+
`forward_list` support frequent insertions and deletions from the middle
|
| 18 |
+
of the sequence. `deque` supports efficient insertions and deletions
|
| 19 |
+
taking place at the beginning or at the end of the sequence. When
|
| 20 |
+
choosing a container, remember `vector` is best; leave a comment to
|
|
|
|
|
|
|
| 21 |
explain if you choose from the rest! — *end note*]
|
| 22 |
|
| 23 |
+
In this subclause,
|
| 24 |
+
|
| 25 |
+
- `X` denotes a sequence container class,
|
| 26 |
+
- `a` denotes a value of type `X` containing elements of type `T`,
|
| 27 |
+
- `u` denotes the name of a variable being declared,
|
| 28 |
+
- `A` denotes `X::allocator_type` if the *qualified-id*
|
| 29 |
`X::allocator_type` is valid and denotes a type [[temp.deduct]] and
|
| 30 |
+
`allocator<T>` if it doesn’t,
|
| 31 |
+
- `i` and `j` denote iterators that meet the *Cpp17InputIterator*
|
| 32 |
+
requirements and refer to elements implicitly convertible to
|
| 33 |
+
`value_type`,
|
| 34 |
+
- `[i, j)` denotes a valid range,
|
| 35 |
+
- `rg` denotes a value of a type `R` that models
|
| 36 |
+
`container-compatible-range<T>`,
|
| 37 |
+
- `il` designates an object of type `initializer_list<value_type>`,
|
| 38 |
+
- `n` denotes a value of type `X::size_type`,
|
| 39 |
+
- `p` denotes a valid constant iterator to `a`,
|
| 40 |
+
- `q` denotes a valid dereferenceable constant iterator to `a`,
|
| 41 |
+
- `[q1, q2)` denotes a valid range of constant iterators in `a`,
|
| 42 |
+
- `t` denotes an lvalue or a const rvalue of `X::value_type`, and
|
| 43 |
+
- `rv` denotes a non-const rvalue of `X::value_type`.
|
| 44 |
+
- `Args` denotes a template parameter pack;
|
| 45 |
+
- `args` denotes a function parameter pack with the pattern `Args&&`.
|
| 46 |
|
| 47 |
The complexities of the expressions are sequence dependent.
|
| 48 |
|
| 49 |
+
A type `X` meets the *sequence container* requirements if `X` meets the
|
| 50 |
+
container requirements and the following statements and expressions are
|
| 51 |
+
well-formed and have the specified semantics.
|
| 52 |
+
|
| 53 |
+
``` cpp
|
| 54 |
+
X u(n, t);
|
| 55 |
+
```
|
| 56 |
+
|
| 57 |
+
*Preconditions:* `T` is *Cpp17CopyInsertable* into `X`.
|
| 58 |
+
|
| 59 |
+
*Effects:* Constructs a sequence container with `n` copies of `t`.
|
| 60 |
+
|
| 61 |
+
*Ensures:* `distance(u.begin(), u.end()) == n` is `true`.
|
| 62 |
+
|
| 63 |
+
``` cpp
|
| 64 |
+
X u(i, j);
|
| 65 |
+
```
|
| 66 |
+
|
| 67 |
+
*Preconditions:* `T` is *Cpp17EmplaceConstructible* into `X` from `*i`.
|
| 68 |
+
For `vector`, if the iterator does not meet the *Cpp17ForwardIterator*
|
| 69 |
+
requirements [[forward.iterators]], `T` is also *Cpp17MoveInsertable*
|
| 70 |
+
into `X`.
|
| 71 |
+
|
| 72 |
+
*Effects:* Constructs a sequence container equal to the range `[i, j)`.
|
| 73 |
+
Each iterator in the range \[`i`, `j`) is dereferenced exactly once.
|
| 74 |
+
|
| 75 |
+
*Ensures:* `distance(u.begin(), u.end()) == distance(i, j)` is `true`.
|
| 76 |
+
|
| 77 |
+
``` cpp
|
| 78 |
+
X(from_range, rg)
|
| 79 |
+
```
|
| 80 |
+
|
| 81 |
+
*Preconditions:* `T` is *Cpp17EmplaceConstructible* into `X` from
|
| 82 |
+
`*ranges::begin(rg)`. For `vector`, if `R` models neither
|
| 83 |
+
`ranges::sized_range` nor `ranges::forward_range`, `T` is also
|
| 84 |
+
*Cpp17MoveInsertable* into `X`.
|
| 85 |
+
|
| 86 |
+
*Effects:* Constructs a sequence container equal to the range `rg`. Each
|
| 87 |
+
iterator in the range `rg` is dereferenced exactly once.
|
| 88 |
+
|
| 89 |
+
*Ensures:* `distance(begin(), end()) == ranges::distance(rg)` is `true`.
|
| 90 |
+
|
| 91 |
+
``` cpp
|
| 92 |
+
X(il)
|
| 93 |
+
```
|
| 94 |
+
|
| 95 |
+
*Effects:* Equivalent to `X(il.begin(), il.end())`.
|
| 96 |
+
|
| 97 |
+
``` cpp
|
| 98 |
+
a = il
|
| 99 |
+
```
|
| 100 |
+
|
| 101 |
+
*Result:* `X&`.
|
| 102 |
+
|
| 103 |
+
*Preconditions:* `T` is *Cpp17CopyInsertable* into `X` and
|
| 104 |
+
*Cpp17CopyAssignable*.
|
| 105 |
+
|
| 106 |
+
*Effects:* Assigns the range \[`il.begin()`, `il.end()`) into `a`. All
|
| 107 |
+
existing elements of `a` are either assigned to or destroyed.
|
| 108 |
+
|
| 109 |
+
*Returns:* `*this`.
|
| 110 |
+
|
| 111 |
+
``` cpp
|
| 112 |
+
a.emplace(p, args)
|
| 113 |
+
```
|
| 114 |
+
|
| 115 |
+
*Result:* `iterator`.
|
| 116 |
+
|
| 117 |
+
*Preconditions:* `T` is *Cpp17EmplaceConstructible* into `X` from
|
| 118 |
+
`args`. For `vector` and `deque`, `T` is also *Cpp17MoveInsertable* into
|
| 119 |
+
`X` and *Cpp17MoveAssignable*.
|
| 120 |
+
|
| 121 |
+
*Effects:* Inserts an object of type `T` constructed with
|
| 122 |
+
`std::forward<Args>(args)...` before `p`.
|
| 123 |
+
|
| 124 |
+
[*Note 1*: `args` can directly or indirectly refer to a value in
|
| 125 |
`a`. — *end note*]
|
| 126 |
|
| 127 |
+
*Returns:* An iterator that points to the new element constructed from
|
| 128 |
+
`args` into `a`.
|
| 129 |
|
| 130 |
+
``` cpp
|
| 131 |
+
a.insert(p, t)
|
| 132 |
+
```
|
| 133 |
|
| 134 |
+
*Result:* `iterator`.
|
|
|
|
| 135 |
|
| 136 |
+
*Preconditions:* `T` is *Cpp17CopyInsertable* into `X`. For `vector` and
|
| 137 |
+
`deque`, `T` is also *Cpp17CopyAssignable*.
|
| 138 |
|
| 139 |
+
*Effects:* Inserts a copy of `t` before `p`.
|
|
|
|
| 140 |
|
| 141 |
+
*Returns:* An iterator that points to the copy of `t` inserted into `a`.
|
|
|
|
| 142 |
|
| 143 |
+
``` cpp
|
| 144 |
+
a.insert(p, rv)
|
| 145 |
+
```
|
| 146 |
|
| 147 |
+
*Result:* `iterator`.
|
| 148 |
+
|
| 149 |
+
*Preconditions:* `T` is *Cpp17MoveInsertable* into `X`. For `vector` and
|
| 150 |
+
`deque`, `T` is also *Cpp17MoveAssignable*.
|
| 151 |
+
|
| 152 |
+
*Effects:* Inserts a copy of `rv` before `p`.
|
| 153 |
+
|
| 154 |
+
*Returns:* An iterator that points to the copy of `rv` inserted into
|
| 155 |
+
`a`.
|
| 156 |
+
|
| 157 |
+
``` cpp
|
| 158 |
+
a.insert(p, n, t)
|
| 159 |
+
```
|
| 160 |
+
|
| 161 |
+
*Result:* `iterator`.
|
| 162 |
+
|
| 163 |
+
*Preconditions:* `T` is *Cpp17CopyInsertable* into `X` and
|
| 164 |
+
*Cpp17CopyAssignable*.
|
| 165 |
+
|
| 166 |
+
*Effects:* Inserts `n` copies of `t` before `p`.
|
| 167 |
+
|
| 168 |
+
*Returns:* An iterator that points to the copy of the first element
|
| 169 |
+
inserted into `a`, or `p` if `n == 0`.
|
| 170 |
+
|
| 171 |
+
``` cpp
|
| 172 |
+
a.insert(p, i, j)
|
| 173 |
+
```
|
| 174 |
+
|
| 175 |
+
*Result:* `iterator`.
|
| 176 |
+
|
| 177 |
+
*Preconditions:* `T` is *Cpp17EmplaceConstructible* into `X` from `*i`.
|
| 178 |
+
For `vector` and `deque`, `T` is also *Cpp17MoveInsertable* into `X`,
|
| 179 |
+
and `T` meets the *Cpp17MoveConstructible*, *Cpp17MoveAssignable*, and
|
| 180 |
+
*Cpp17Swappable*[[swappable.requirements]] requirements. Neither `i` nor
|
| 181 |
+
`j` are iterators into `a`.
|
| 182 |
+
|
| 183 |
+
*Effects:* Inserts copies of elements in `[i, j)` before `p`. Each
|
| 184 |
+
iterator in the range \[`i`, `j`) shall be dereferenced exactly once.
|
| 185 |
+
|
| 186 |
+
*Returns:* An iterator that points to the copy of the first element
|
| 187 |
+
inserted into `a`, or `p` if `i == j`.
|
| 188 |
+
|
| 189 |
+
``` cpp
|
| 190 |
+
a.insert_range(p, rg)
|
| 191 |
+
```
|
| 192 |
+
|
| 193 |
+
*Result:* `iterator`.
|
| 194 |
+
|
| 195 |
+
*Preconditions:* `T` is *Cpp17EmplaceConstructible* into `X` from
|
| 196 |
+
`*ranges::begin(rg)`. For `vector` and `deque`, `T` is also
|
| 197 |
+
*Cpp17MoveInsertable* into `X`, and `T` meets the
|
| 198 |
+
*Cpp17MoveConstructible*, *Cpp17MoveAssignable*, and
|
| 199 |
+
*Cpp17Swappable*[[swappable.requirements]] requirements. `rg` and `a` do
|
| 200 |
+
not overlap.
|
| 201 |
+
|
| 202 |
+
*Effects:* Inserts copies of elements in `rg` before `p`. Each iterator
|
| 203 |
+
in the range `rg` is dereferenced exactly once.
|
| 204 |
+
|
| 205 |
+
*Returns:* An iterator that points to the copy of the first element
|
| 206 |
+
inserted into `a`, or `p` if `rg` is empty.
|
| 207 |
+
|
| 208 |
+
``` cpp
|
| 209 |
+
a.insert(p, il)
|
| 210 |
+
```
|
| 211 |
+
|
| 212 |
+
*Effects:* Equivalent to `a.insert(p, il.begin(), il.end())`.
|
| 213 |
+
|
| 214 |
+
``` cpp
|
| 215 |
+
a.erase(q)
|
| 216 |
+
```
|
| 217 |
+
|
| 218 |
+
*Result:* `iterator`.
|
| 219 |
+
|
| 220 |
+
*Preconditions:* For `vector` and `deque`, `T` is *Cpp17MoveAssignable*.
|
| 221 |
+
|
| 222 |
+
*Effects:* Erases the element pointed to by `q`.
|
| 223 |
+
|
| 224 |
+
*Returns:* An iterator that points to the element immediately following
|
| 225 |
+
`q` prior to the element being erased. If no such element exists,
|
| 226 |
+
`a.end()` is returned.
|
| 227 |
+
|
| 228 |
+
``` cpp
|
| 229 |
+
a.erase(q1, q2)
|
| 230 |
+
```
|
| 231 |
+
|
| 232 |
+
*Result:* `iterator`.
|
| 233 |
+
|
| 234 |
+
*Preconditions:* For `vector` and `deque`, `T` is *Cpp17MoveAssignable*.
|
| 235 |
+
|
| 236 |
+
*Effects:* Erases the elements in the range `[q1, q2)`.
|
| 237 |
+
|
| 238 |
+
*Returns:* An iterator that points to the element pointed to by `q2`
|
| 239 |
+
prior to any elements being erased. If no such element exists, `a.end()`
|
| 240 |
+
is returned.
|
| 241 |
+
|
| 242 |
+
``` cpp
|
| 243 |
+
a.clear()
|
| 244 |
+
```
|
| 245 |
+
|
| 246 |
+
*Result:* `void`
|
| 247 |
+
|
| 248 |
+
*Effects:* Destroys all elements in `a`. Invalidates all references,
|
| 249 |
+
pointers, and iterators referring to the elements of `a` and may
|
| 250 |
+
invalidate the past-the-end iterator.
|
| 251 |
+
|
| 252 |
+
*Ensures:* `a.empty()` is `true`.
|
| 253 |
+
|
| 254 |
+
*Complexity:* Linear.
|
| 255 |
+
|
| 256 |
+
``` cpp
|
| 257 |
+
a.assign(i, j)
|
| 258 |
+
```
|
| 259 |
+
|
| 260 |
+
*Result:* `void`
|
| 261 |
+
|
| 262 |
+
*Preconditions:* `T` is *Cpp17EmplaceConstructible* into `X` from `*i`
|
| 263 |
+
and assignable from `*i`. For `vector`, if the iterator does not meet
|
| 264 |
+
the forward iterator requirements [[forward.iterators]], `T` is also
|
| 265 |
+
*Cpp17MoveInsertable* into `X`. Neither `i` nor `j` are iterators into
|
| 266 |
+
`a`.
|
| 267 |
+
|
| 268 |
+
*Effects:* Replaces elements in `a` with a copy of `[i, j)`. Invalidates
|
| 269 |
+
all references, pointers and iterators referring to the elements of `a`.
|
| 270 |
+
For `vector` and `deque`, also invalidates the past-the-end iterator.
|
| 271 |
+
Each iterator in the range \[`i`, `j`) is dereferenced exactly once.
|
| 272 |
+
|
| 273 |
+
``` cpp
|
| 274 |
+
a.assign_range(rg)
|
| 275 |
+
```
|
| 276 |
+
|
| 277 |
+
*Result:* `void`
|
| 278 |
+
|
| 279 |
+
*Mandates:* `assignable_from<T&, ranges::range_reference_t<R>>` is
|
| 280 |
+
modeled.
|
| 281 |
+
|
| 282 |
+
*Preconditions:* `T` is *Cpp17EmplaceConstructible* into `X` from
|
| 283 |
+
`*ranges::begin(rg)`. For `vector`, if `R` models neither
|
| 284 |
+
`ranges::sized_range` nor `ranges::forward_range`, `T` is also
|
| 285 |
+
*Cpp17MoveInsertable* into `X`. `rg` and `a` do not overlap.
|
| 286 |
+
|
| 287 |
+
*Effects:* Replaces elements in `a` with a copy of each element in `rg`.
|
| 288 |
+
Invalidates all references, pointers, and iterators referring to the
|
| 289 |
+
elements of `a`. For `vector` and `deque`, also invalidates the
|
| 290 |
+
past-the-end iterator. Each iterator in the range `rg` is dereferenced
|
| 291 |
+
exactly once.
|
| 292 |
+
|
| 293 |
+
``` cpp
|
| 294 |
+
a.assign(il)
|
| 295 |
+
```
|
| 296 |
+
|
| 297 |
+
*Effects:* Equivalent to `a.assign(il.begin(), il.end())`.
|
| 298 |
+
|
| 299 |
+
``` cpp
|
| 300 |
+
a.assign(n, t)
|
| 301 |
+
```
|
| 302 |
+
|
| 303 |
+
*Result:* `void`
|
| 304 |
+
|
| 305 |
+
*Preconditions:* `T` is *Cpp17CopyInsertable* into `X` and
|
| 306 |
+
*Cpp17CopyAssignable*. `t` is not a reference into `a`.
|
| 307 |
+
|
| 308 |
+
*Effects:* Replaces elements in `a` with `n` copies of `t`. Invalidates
|
| 309 |
+
all references, pointers and iterators referring to the elements of `a`.
|
| 310 |
+
For `vector` and `deque`, also invalidates the past-the-end iterator.
|
| 311 |
|
| 312 |
For every sequence container defined in this Clause and in [[strings]]:
|
| 313 |
|
| 314 |
- If the constructor
|
| 315 |
``` cpp
|
|
|
|
| 343 |
and a type that does not qualify as an input iterator is deduced for
|
| 344 |
that parameter, or if it has an `Allocator` template parameter and a
|
| 345 |
type that does not qualify as an allocator is deduced for that
|
| 346 |
parameter.
|
| 347 |
|
| 348 |
+
The following operations are provided for some types of sequence
|
| 349 |
+
containers but not others. Operations other than `prepend_range` and
|
| 350 |
+
`append_range` are implemented so as to take amortized constant time.
|
|
|
|
| 351 |
|
| 352 |
+
``` cpp
|
| 353 |
+
a.front()
|
| 354 |
+
```
|
| 355 |
+
|
| 356 |
+
*Result:* `reference; const_reference` for constant `a`.
|
| 357 |
+
|
| 358 |
+
*Returns:* `*a.begin()`
|
| 359 |
+
|
| 360 |
+
*Remarks:* Required for `basic_string`, `array`, `deque`,
|
| 361 |
+
`forward_list`, `list`, and `vector`.
|
| 362 |
+
|
| 363 |
+
``` cpp
|
| 364 |
+
a.back()
|
| 365 |
+
```
|
| 366 |
+
|
| 367 |
+
*Result:* `reference; const_reference` for constant `a`.
|
| 368 |
+
|
| 369 |
+
*Effects:* Equivalent to:
|
| 370 |
+
|
| 371 |
+
``` cpp
|
| 372 |
+
auto tmp = a.end();
|
| 373 |
+
--tmp;
|
| 374 |
+
return *tmp;
|
| 375 |
+
```
|
| 376 |
+
|
| 377 |
+
*Remarks:* Required for `basic_string`, `array`, `deque`, `list`, and
|
| 378 |
+
`vector`.
|
| 379 |
+
|
| 380 |
+
``` cpp
|
| 381 |
+
a.emplace_front(args)
|
| 382 |
+
```
|
| 383 |
+
|
| 384 |
+
*Result:* `reference`
|
| 385 |
+
|
| 386 |
+
*Preconditions:* `T` is *Cpp17EmplaceConstructible* into `X` from
|
| 387 |
+
`args`.
|
| 388 |
+
|
| 389 |
+
*Effects:* Prepends an object of type `T` constructed with
|
| 390 |
+
`std::forward<Args>(args)...`.
|
| 391 |
+
|
| 392 |
+
*Returns:* `a.front()`.
|
| 393 |
+
|
| 394 |
+
*Remarks:* Required for `deque`, `forward_list`, and `list`.
|
| 395 |
+
|
| 396 |
+
``` cpp
|
| 397 |
+
a.emplace_back(args)
|
| 398 |
+
```
|
| 399 |
+
|
| 400 |
+
*Result:* `reference`
|
| 401 |
+
|
| 402 |
+
*Preconditions:* `T` is *Cpp17EmplaceConstructible* into `X` from
|
| 403 |
+
`args`. For `vector`, `T` is also *Cpp17MoveInsertable* into `X`.
|
| 404 |
+
|
| 405 |
+
*Effects:* Appends an object of type `T` constructed with
|
| 406 |
+
`std::forward<Args>(args)...`.
|
| 407 |
+
|
| 408 |
+
*Returns:* `a.back()`.
|
| 409 |
+
|
| 410 |
+
*Remarks:* Required for `deque`, `list`, and `vector`.
|
| 411 |
+
|
| 412 |
+
``` cpp
|
| 413 |
+
a.push_front(t)
|
| 414 |
+
```
|
| 415 |
+
|
| 416 |
+
*Result:* `void`
|
| 417 |
+
|
| 418 |
+
*Preconditions:* `T` is *Cpp17CopyInsertable* into `X`.
|
| 419 |
+
|
| 420 |
+
*Effects:* Prepends a copy of `t`.
|
| 421 |
+
|
| 422 |
+
*Remarks:* Required for `deque`, `forward_list`, and `list`.
|
| 423 |
+
|
| 424 |
+
``` cpp
|
| 425 |
+
a.push_front(rv)
|
| 426 |
+
```
|
| 427 |
+
|
| 428 |
+
*Result:* `void`
|
| 429 |
+
|
| 430 |
+
*Preconditions:* `T` is *Cpp17MoveInsertable* into `X`.
|
| 431 |
+
|
| 432 |
+
*Effects:* Prepends a copy of `rv`.
|
| 433 |
+
|
| 434 |
+
*Remarks:* Required for `deque`, `forward_list`, and `list`.
|
| 435 |
+
|
| 436 |
+
``` cpp
|
| 437 |
+
a.prepend_range(rg)
|
| 438 |
+
```
|
| 439 |
+
|
| 440 |
+
*Result:* `void`
|
| 441 |
+
|
| 442 |
+
*Preconditions:* `T` is *Cpp17EmplaceConstructible* into `X` from
|
| 443 |
+
`*ranges::begin(rg)`. For `deque`, `T` is also *Cpp17MoveInsertable*
|
| 444 |
+
into `X`, and `T` meets the *Cpp17MoveConstructible*,
|
| 445 |
+
*Cpp17MoveAssignable*, and *Cpp17Swappable*[[swappable.requirements]]
|
| 446 |
+
requirements.
|
| 447 |
+
|
| 448 |
+
*Effects:* Inserts copies of elements in `rg` before `begin()`. Each
|
| 449 |
+
iterator in the range `rg` is dereferenced exactly once.
|
| 450 |
+
|
| 451 |
+
[*Note 2*: The order of elements in `rg` is not
|
| 452 |
+
reversed. — *end note*]
|
| 453 |
+
|
| 454 |
+
*Remarks:* Required for `deque`, `forward_list`, and `list`.
|
| 455 |
+
|
| 456 |
+
``` cpp
|
| 457 |
+
a.push_back(t)
|
| 458 |
+
```
|
| 459 |
+
|
| 460 |
+
*Result:* `void`
|
| 461 |
+
|
| 462 |
+
*Preconditions:* `T` is *Cpp17CopyInsertable* into `X`.
|
| 463 |
+
|
| 464 |
+
*Effects:* Appends a copy of `t`.
|
| 465 |
+
|
| 466 |
+
*Remarks:* Required for `basic_string`, `deque`, `list`, and `vector`.
|
| 467 |
+
|
| 468 |
+
``` cpp
|
| 469 |
+
a.push_back(rv)
|
| 470 |
+
```
|
| 471 |
+
|
| 472 |
+
*Result:* `void`
|
| 473 |
+
|
| 474 |
+
*Preconditions:* `T` is *Cpp17MoveInsertable* into `X`.
|
| 475 |
+
|
| 476 |
+
*Effects:* Appends a copy of `rv`.
|
| 477 |
+
|
| 478 |
+
*Remarks:* Required for `basic_string`, `deque`, `list`, and `vector`.
|
| 479 |
+
|
| 480 |
+
``` cpp
|
| 481 |
+
a.append_range(rg)
|
| 482 |
+
```
|
| 483 |
+
|
| 484 |
+
*Result:* `void`
|
| 485 |
+
|
| 486 |
+
*Preconditions:* `T` is *Cpp17EmplaceConstructible* into `X` from
|
| 487 |
+
`*ranges::begin(rg)`. For `vector`, `T` is also *Cpp17MoveInsertable*
|
| 488 |
+
into `X`.
|
| 489 |
+
|
| 490 |
+
*Effects:* Inserts copies of elements in `rg` before `end()`. Each
|
| 491 |
+
iterator in the range `rg` is dereferenced exactly once.
|
| 492 |
+
|
| 493 |
+
*Remarks:* Required for `deque`, `list`, and `vector`.
|
| 494 |
+
|
| 495 |
+
``` cpp
|
| 496 |
+
a.pop_front()
|
| 497 |
+
```
|
| 498 |
+
|
| 499 |
+
*Result:* `void`
|
| 500 |
+
|
| 501 |
+
*Preconditions:* `a.empty()` is `false`.
|
| 502 |
+
|
| 503 |
+
*Effects:* Destroys the first element.
|
| 504 |
+
|
| 505 |
+
*Remarks:* Required for `deque`, `forward_list`, and `list`.
|
| 506 |
+
|
| 507 |
+
``` cpp
|
| 508 |
+
a.pop_back()
|
| 509 |
+
```
|
| 510 |
+
|
| 511 |
+
*Result:* `void`
|
| 512 |
+
|
| 513 |
+
*Preconditions:* `a.empty()` is `false`.
|
| 514 |
+
|
| 515 |
+
*Effects:* Destroys the last element.
|
| 516 |
+
|
| 517 |
+
*Remarks:* Required for `basic_string`, `deque`, `list`, and `vector`.
|
| 518 |
+
|
| 519 |
+
``` cpp
|
| 520 |
+
a[n]
|
| 521 |
+
```
|
| 522 |
+
|
| 523 |
+
*Result:* `reference; const_reference` for constant `a`
|
| 524 |
+
|
| 525 |
+
*Returns:* `*(a.begin() + n)`
|
| 526 |
+
|
| 527 |
+
*Remarks:* Required for `basic_string`, `array`, `deque`, and `vector`.
|
| 528 |
+
|
| 529 |
+
``` cpp
|
| 530 |
+
a.at(n)
|
| 531 |
+
```
|
| 532 |
+
|
| 533 |
+
*Result:* `reference; const_reference` for constant `a`
|
| 534 |
+
|
| 535 |
+
*Returns:* `*(a.begin() + n)`
|
| 536 |
+
|
| 537 |
+
*Throws:* `out_of_range` if `n >= a.size()`.
|
| 538 |
+
|
| 539 |
+
*Remarks:* Required for `basic_string`, `array`, `deque`, and `vector`.
|
| 540 |
|