- tmp/tmpupv5zbn9/{from.md → to.md} +148 -140
tmp/tmpupv5zbn9/{from.md → to.md}
RENAMED
|
@@ -18,137 +18,143 @@ provided.[^2]
|
|
| 18 |
|
| 19 |
Descriptions are provided here only for operations on `list` that are
|
| 20 |
not described in one of these tables or for operations where there is
|
| 21 |
additional semantic information.
|
| 22 |
|
|
|
|
|
|
|
|
|
|
| 23 |
``` cpp
|
| 24 |
namespace std {
|
| 25 |
template<class T, class Allocator = allocator<T>>
|
| 26 |
class list {
|
| 27 |
public:
|
| 28 |
// types
|
| 29 |
using value_type = T;
|
| 30 |
using allocator_type = Allocator;
|
| 31 |
-
using pointer =
|
| 32 |
-
using const_pointer =
|
| 33 |
using reference = value_type&;
|
| 34 |
using const_reference = const value_type&;
|
| 35 |
using size_type = implementation-defined // type of list::size_type; // see [container.requirements]
|
| 36 |
using difference_type = implementation-defined // type of list::difference_type; // see [container.requirements]
|
| 37 |
using iterator = implementation-defined // type of list::iterator; // see [container.requirements]
|
| 38 |
using const_iterator = implementation-defined // type of list::const_iterator; // see [container.requirements]
|
| 39 |
using reverse_iterator = std::reverse_iterator<iterator>;
|
| 40 |
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
|
| 41 |
|
| 42 |
// [list.cons], construct/copy/destroy
|
| 43 |
-
list() : list(Allocator()) { }
|
| 44 |
-
explicit list(const Allocator&);
|
| 45 |
-
explicit list(size_type n, const Allocator& = Allocator());
|
| 46 |
-
list(size_type n, const T& value, const Allocator& = Allocator());
|
| 47 |
template<class InputIterator>
|
| 48 |
-
list(InputIterator first, InputIterator last, const Allocator& = Allocator());
|
| 49 |
template<container-compatible-range<T> R>
|
| 50 |
-
list(from_range_t, R&& rg, const Allocator& = Allocator());
|
| 51 |
-
list(const list& x);
|
| 52 |
-
list(list&& x);
|
| 53 |
-
list(const list&, const type_identity_t<Allocator>&);
|
| 54 |
-
list(list&&, const type_identity_t<Allocator>&);
|
| 55 |
-
list(initializer_list<T>, const Allocator& = Allocator());
|
| 56 |
-
~list();
|
| 57 |
-
list& operator=(const list& x);
|
| 58 |
-
list& operator=(list&& x)
|
| 59 |
noexcept(allocator_traits<Allocator>::is_always_equal::value);
|
| 60 |
-
list& operator=(initializer_list<T>);
|
| 61 |
template<class InputIterator>
|
| 62 |
-
void assign(InputIterator first, InputIterator last);
|
| 63 |
template<container-compatible-range<T> R>
|
| 64 |
-
void assign_range(R&& rg);
|
| 65 |
-
void assign(size_type n, const T& t);
|
| 66 |
-
void assign(initializer_list<T>);
|
| 67 |
-
allocator_type get_allocator() const noexcept;
|
| 68 |
|
| 69 |
// iterators
|
| 70 |
-
iterator begin() noexcept;
|
| 71 |
-
const_iterator begin() const noexcept;
|
| 72 |
-
iterator end() noexcept;
|
| 73 |
-
const_iterator end() const noexcept;
|
| 74 |
-
reverse_iterator rbegin() noexcept;
|
| 75 |
-
const_reverse_iterator rbegin() const noexcept;
|
| 76 |
-
reverse_iterator rend() noexcept;
|
| 77 |
-
const_reverse_iterator rend() const noexcept;
|
| 78 |
|
| 79 |
-
const_iterator cbegin() const noexcept;
|
| 80 |
-
const_iterator cend() const noexcept;
|
| 81 |
-
const_reverse_iterator crbegin() const noexcept;
|
| 82 |
-
const_reverse_iterator crend() const noexcept;
|
| 83 |
|
| 84 |
// [list.capacity], capacity
|
| 85 |
-
|
| 86 |
-
size_type size() const noexcept;
|
| 87 |
-
size_type max_size() const noexcept;
|
| 88 |
-
void resize(size_type sz);
|
| 89 |
-
void resize(size_type sz, const T& c);
|
| 90 |
|
| 91 |
// element access
|
| 92 |
-
reference front();
|
| 93 |
-
const_reference front() const;
|
| 94 |
-
reference back();
|
| 95 |
-
const_reference back() const;
|
| 96 |
|
| 97 |
// [list.modifiers], modifiers
|
| 98 |
-
template<class... Args> reference emplace_front(Args&&... args);
|
| 99 |
-
template<class... Args> reference emplace_back(Args&&... args);
|
| 100 |
-
void push_front(const T& x);
|
| 101 |
-
void push_front(T&& x);
|
| 102 |
template<container-compatible-range<T> R>
|
| 103 |
-
void prepend_range(R&& rg);
|
| 104 |
-
void pop_front();
|
| 105 |
-
void push_back(const T& x);
|
| 106 |
-
void push_back(T&& x);
|
| 107 |
template<container-compatible-range<T> R>
|
| 108 |
-
void append_range(R&& rg);
|
| 109 |
-
void pop_back();
|
| 110 |
|
| 111 |
-
template<class... Args> iterator emplace(const_iterator position, Args&&... args);
|
| 112 |
-
iterator insert(const_iterator position, const T& x);
|
| 113 |
-
iterator insert(const_iterator position, T&& x);
|
| 114 |
-
iterator insert(const_iterator position, size_type n, const T& x);
|
| 115 |
template<class InputIterator>
|
| 116 |
-
iterator insert(const_iterator position,
|
|
|
|
| 117 |
template<container-compatible-range<T> R>
|
| 118 |
-
iterator insert_range(const_iterator position, R&& rg);
|
| 119 |
-
iterator insert(const_iterator position, initializer_list<T> il);
|
| 120 |
|
| 121 |
-
iterator erase(const_iterator position);
|
| 122 |
-
iterator erase(const_iterator position, const_iterator last);
|
| 123 |
-
void swap(list&) noexcept(allocator_traits<Allocator>::is_always_equal::value);
|
| 124 |
-
void clear() noexcept;
|
| 125 |
|
| 126 |
// [list.ops], list operations
|
| 127 |
-
void splice(const_iterator position, list& x);
|
| 128 |
-
void splice(const_iterator position, list&& x);
|
| 129 |
-
void splice(const_iterator position, list& x, const_iterator i);
|
| 130 |
-
void splice(const_iterator position, list&& x, const_iterator i);
|
| 131 |
-
void splice(const_iterator position, list& x,
|
| 132 |
-
|
|
|
|
|
|
|
| 133 |
|
| 134 |
-
size_type remove(const T& value);
|
| 135 |
-
template<class Predicate> size_type remove_if(Predicate pred);
|
| 136 |
|
| 137 |
-
size_type unique();
|
| 138 |
template<class BinaryPredicate>
|
| 139 |
-
size_type unique(BinaryPredicate binary_pred);
|
| 140 |
|
| 141 |
-
void merge(list& x);
|
| 142 |
-
void merge(list&& x);
|
| 143 |
-
template<class Compare> void merge(list& x, Compare comp);
|
| 144 |
-
template<class Compare> void merge(list&& x, Compare comp);
|
| 145 |
|
| 146 |
-
void sort();
|
| 147 |
-
template<class Compare> void sort(Compare comp);
|
| 148 |
|
| 149 |
-
void reverse() noexcept;
|
| 150 |
};
|
| 151 |
|
| 152 |
template<class InputIterator, class Allocator = allocator<iter-value-type<InputIterator>>>
|
| 153 |
list(InputIterator, InputIterator, Allocator = Allocator())
|
| 154 |
-> list<iter-value-type<InputIterator>, Allocator>;
|
|
@@ -165,65 +171,65 @@ allocator meets the allocator completeness requirements
|
|
| 165 |
any member of the resulting specialization of `list` is referenced.
|
| 166 |
|
| 167 |
#### Constructors, copy, and assignment <a id="list.cons">[[list.cons]]</a>
|
| 168 |
|
| 169 |
``` cpp
|
| 170 |
-
explicit list(const Allocator&);
|
| 171 |
```
|
| 172 |
|
| 173 |
*Effects:* Constructs an empty list, using the specified allocator.
|
| 174 |
|
| 175 |
*Complexity:* Constant.
|
| 176 |
|
| 177 |
``` cpp
|
| 178 |
-
explicit list(size_type n, const Allocator& = Allocator());
|
| 179 |
```
|
| 180 |
|
| 181 |
-
*Preconditions:* `T` is *Cpp17DefaultInsertable* into `
|
| 182 |
|
| 183 |
*Effects:* Constructs a `list` with `n` default-inserted elements using
|
| 184 |
the specified allocator.
|
| 185 |
|
| 186 |
*Complexity:* Linear in `n`.
|
| 187 |
|
| 188 |
``` cpp
|
| 189 |
-
list(size_type n, const T& value, const Allocator& = Allocator());
|
| 190 |
```
|
| 191 |
|
| 192 |
-
*Preconditions:* `T` is *Cpp17CopyInsertable* into `
|
| 193 |
|
| 194 |
*Effects:* Constructs a `list` with `n` copies of `value`, using the
|
| 195 |
specified allocator.
|
| 196 |
|
| 197 |
*Complexity:* Linear in `n`.
|
| 198 |
|
| 199 |
``` cpp
|
| 200 |
template<class InputIterator>
|
| 201 |
-
list(InputIterator first, InputIterator last, const Allocator& = Allocator());
|
| 202 |
```
|
| 203 |
|
| 204 |
*Effects:* Constructs a `list` equal to the range \[`first`, `last`).
|
| 205 |
|
| 206 |
*Complexity:* Linear in `distance(first, last)`.
|
| 207 |
|
| 208 |
``` cpp
|
| 209 |
template<container-compatible-range<T> R>
|
| 210 |
-
list(from_range_t, R&& rg, const Allocator& = Allocator());
|
| 211 |
```
|
| 212 |
|
| 213 |
*Effects:* Constructs a `list` object with the elements of the range
|
| 214 |
`rg`.
|
| 215 |
|
| 216 |
*Complexity:* Linear in `ranges::distance(rg)`.
|
| 217 |
|
| 218 |
#### Capacity <a id="list.capacity">[[list.capacity]]</a>
|
| 219 |
|
| 220 |
``` cpp
|
| 221 |
-
void resize(size_type sz);
|
| 222 |
```
|
| 223 |
|
| 224 |
-
*Preconditions:* `T` is *Cpp17DefaultInsertable* into `
|
| 225 |
|
| 226 |
*Effects:* If `size() < sz`, appends `sz - size()` default-inserted
|
| 227 |
elements to the sequence. If `sz <= size()`, equivalent to:
|
| 228 |
|
| 229 |
``` cpp
|
|
@@ -231,14 +237,14 @@ list<T>::iterator it = begin();
|
|
| 231 |
advance(it, sz);
|
| 232 |
erase(it, end());
|
| 233 |
```
|
| 234 |
|
| 235 |
``` cpp
|
| 236 |
-
void resize(size_type sz, const T& c);
|
| 237 |
```
|
| 238 |
|
| 239 |
-
*Preconditions:* `T` is *Cpp17CopyInsertable* into `
|
| 240 |
|
| 241 |
*Effects:* As if by:
|
| 242 |
|
| 243 |
``` cpp
|
| 244 |
if (sz > size())
|
|
@@ -253,49 +259,48 @@ else
|
|
| 253 |
```
|
| 254 |
|
| 255 |
#### Modifiers <a id="list.modifiers">[[list.modifiers]]</a>
|
| 256 |
|
| 257 |
``` cpp
|
| 258 |
-
iterator insert(const_iterator position, const T& x);
|
| 259 |
-
iterator insert(const_iterator position, T&& x);
|
| 260 |
-
iterator insert(const_iterator position, size_type n, const T& x);
|
| 261 |
template<class InputIterator>
|
| 262 |
-
iterator insert(const_iterator position,
|
| 263 |
-
|
| 264 |
template<container-compatible-range<T> R>
|
| 265 |
-
iterator insert_range(const_iterator position, R&& rg);
|
| 266 |
-
iterator insert(const_iterator position, initializer_list<T>);
|
| 267 |
|
| 268 |
-
template<class... Args> reference emplace_front(Args&&... args);
|
| 269 |
-
template<class... Args> reference emplace_back(Args&&... args);
|
| 270 |
-
template<class... Args> iterator emplace(const_iterator position, Args&&... args);
|
| 271 |
-
void push_front(const T& x);
|
| 272 |
-
void push_front(T&& x);
|
| 273 |
template<container-compatible-range<T> R>
|
| 274 |
-
void prepend_range(R&& rg);
|
| 275 |
-
void push_back(const T& x);
|
| 276 |
-
void push_back(T&& x);
|
| 277 |
template<container-compatible-range<T> R>
|
| 278 |
-
void append_range(R&& rg);
|
| 279 |
```
|
| 280 |
|
| 281 |
*Complexity:* Insertion of a single element into a list takes constant
|
| 282 |
time and exactly one call to a constructor of `T`. Insertion of multiple
|
| 283 |
elements into a list is linear in the number of elements inserted, and
|
| 284 |
the number of calls to the copy constructor or move constructor of `T`
|
| 285 |
is exactly equal to the number of elements inserted.
|
| 286 |
|
| 287 |
*Remarks:* Does not affect the validity of iterators and references. If
|
| 288 |
-
an exception is thrown there are no effects.
|
| 289 |
|
| 290 |
``` cpp
|
| 291 |
-
iterator erase(const_iterator position);
|
| 292 |
-
iterator erase(const_iterator first, const_iterator last);
|
| 293 |
-
|
| 294 |
-
void
|
| 295 |
-
void
|
| 296 |
-
void clear() noexcept;
|
| 297 |
```
|
| 298 |
|
| 299 |
*Effects:* Invalidates only the iterators and references to the erased
|
| 300 |
elements.
|
| 301 |
|
|
@@ -322,12 +327,12 @@ those of `next(i, n)` and `prev(i, n)`, respectively. For `merge` and
|
|
| 322 |
from one list to another. The behavior of splice operations is undefined
|
| 323 |
if `get_allocator() !=
|
| 324 |
x.get_allocator()`.
|
| 325 |
|
| 326 |
``` cpp
|
| 327 |
-
void splice(const_iterator position, list& x);
|
| 328 |
-
void splice(const_iterator position, list&& x);
|
| 329 |
```
|
| 330 |
|
| 331 |
*Preconditions:* `addressof(x) != this` is `true`.
|
| 332 |
|
| 333 |
*Effects:* Inserts the contents of `x` before `position` and `x` becomes
|
|
@@ -339,12 +344,12 @@ now behave as iterators into `*this`, not into `x`.
|
|
| 339 |
*Throws:* Nothing.
|
| 340 |
|
| 341 |
*Complexity:* Constant time.
|
| 342 |
|
| 343 |
``` cpp
|
| 344 |
-
void splice(const_iterator position, list& x, const_iterator i);
|
| 345 |
-
void splice(const_iterator position, list&& x, const_iterator i);
|
| 346 |
```
|
| 347 |
|
| 348 |
*Preconditions:* `i` is a valid dereferenceable iterator of `x`.
|
| 349 |
|
| 350 |
*Effects:* Inserts an element pointed to by `i` from list `x` before
|
|
@@ -357,18 +362,18 @@ element, but now behave as iterators into `*this`, not into `x`.
|
|
| 357 |
*Throws:* Nothing.
|
| 358 |
|
| 359 |
*Complexity:* Constant time.
|
| 360 |
|
| 361 |
``` cpp
|
| 362 |
-
void splice(const_iterator position, list& x,
|
| 363 |
-
|
| 364 |
-
void splice(const_iterator position, list&& x,
|
| 365 |
-
|
| 366 |
```
|
| 367 |
|
| 368 |
-
*Preconditions:*
|
| 369 |
-
not an iterator in the range \[`first`, `last`).
|
| 370 |
|
| 371 |
*Effects:* Inserts elements in the range \[`first`, `last`) before
|
| 372 |
`position` and removes the elements from `x`. Pointers and references to
|
| 373 |
the moved elements of `x` now refer to those same elements but as
|
| 374 |
members of `*this`. Iterators referring to the moved elements will
|
|
@@ -379,12 +384,12 @@ into `*this`, not into `x`.
|
|
| 379 |
|
| 380 |
*Complexity:* Constant time if `addressof(x) == this`; otherwise, linear
|
| 381 |
time.
|
| 382 |
|
| 383 |
``` cpp
|
| 384 |
-
size_type remove(const T& value);
|
| 385 |
-
template<class Predicate> size_type remove_if(Predicate pred);
|
| 386 |
```
|
| 387 |
|
| 388 |
*Effects:* Erases all the elements in the list referred to by a list
|
| 389 |
iterator `i` for which the following conditions hold: `*i == value`,
|
| 390 |
`pred(*i) != false`. Invalidates only the iterators and references to
|
|
@@ -399,12 +404,12 @@ the erased elements.
|
|
| 399 |
predicate.
|
| 400 |
|
| 401 |
*Remarks:* Stable [[algorithm.stable]].
|
| 402 |
|
| 403 |
``` cpp
|
| 404 |
-
size_type unique();
|
| 405 |
-
template<class BinaryPredicate> size_type unique(BinaryPredicate binary_pred);
|
| 406 |
```
|
| 407 |
|
| 408 |
Let `binary_pred` be `equal_to<>{}` for the first overload.
|
| 409 |
|
| 410 |
*Preconditions:* `binary_pred` is an equivalence relation.
|
|
@@ -422,14 +427,14 @@ only the iterators and references to the erased elements.
|
|
| 422 |
*Complexity:* If `empty()` is `false`, exactly `size() - 1` applications
|
| 423 |
of the corresponding predicate, otherwise no applications of the
|
| 424 |
predicate.
|
| 425 |
|
| 426 |
``` cpp
|
| 427 |
-
void merge(list& x);
|
| 428 |
-
void merge(list&& x);
|
| 429 |
-
template<class Compare> void merge(list& x, Compare comp);
|
| 430 |
-
template<class Compare> void merge(list&& x, Compare comp);
|
| 431 |
```
|
| 432 |
|
| 433 |
Let `comp` be `less<>` for the first two overloads.
|
| 434 |
|
| 435 |
*Preconditions:* `*this` and `x` are both sorted with respect to the
|
|
@@ -446,14 +451,14 @@ elements, but they now behave as iterators into `*this`, not into `x`.
|
|
| 446 |
*Complexity:* At most `size() + x.size() - 1` comparisons if
|
| 447 |
`addressof(x) != this`; otherwise, no comparisons are performed.
|
| 448 |
|
| 449 |
*Remarks:* Stable [[algorithm.stable]]. If `addressof(x) != this`, `x`
|
| 450 |
is empty after the merge. No elements are copied by this operation. If
|
| 451 |
-
an exception is thrown other than by a comparison there are no effects.
|
| 452 |
|
| 453 |
``` cpp
|
| 454 |
-
void reverse() noexcept;
|
| 455 |
```
|
| 456 |
|
| 457 |
*Effects:* Reverses the order of the elements in the list. Does not
|
| 458 |
affect the validity of iterators and references.
|
| 459 |
|
|
@@ -467,28 +472,31 @@ template<class Compare> void sort(Compare comp);
|
|
| 467 |
*Effects:* Sorts the list according to the `operator<` or a `Compare`
|
| 468 |
function object. If an exception is thrown, the order of the elements in
|
| 469 |
`*this` is unspecified. Does not affect the validity of iterators and
|
| 470 |
references.
|
| 471 |
|
| 472 |
-
*Complexity:* Approximately N log N comparisons, where
|
| 473 |
|
| 474 |
*Remarks:* Stable [[algorithm.stable]].
|
| 475 |
|
| 476 |
#### Erasure <a id="list.erasure">[[list.erasure]]</a>
|
| 477 |
|
| 478 |
``` cpp
|
| 479 |
-
template<class T, class Allocator, class U>
|
| 480 |
typename list<T, Allocator>::size_type
|
| 481 |
-
erase(list<T, Allocator>& c, const U& value);
|
| 482 |
```
|
| 483 |
|
| 484 |
*Effects:* Equivalent to:
|
| 485 |
-
|
|
|
|
|
|
|
|
|
|
| 486 |
|
| 487 |
``` cpp
|
| 488 |
template<class T, class Allocator, class Predicate>
|
| 489 |
typename list<T, Allocator>::size_type
|
| 490 |
-
erase_if(list<T, Allocator>& c, Predicate pred);
|
| 491 |
```
|
| 492 |
|
| 493 |
*Effects:* Equivalent to: `return c.remove_if(pred);`
|
| 494 |
|
|
|
|
| 18 |
|
| 19 |
Descriptions are provided here only for operations on `list` that are
|
| 20 |
not described in one of these tables or for operations where there is
|
| 21 |
additional semantic information.
|
| 22 |
|
| 23 |
+
The types `iterator` and `const_iterator` meet the constexpr iterator
|
| 24 |
+
requirements [[iterator.requirements.general]].
|
| 25 |
+
|
| 26 |
``` cpp
|
| 27 |
namespace std {
|
| 28 |
template<class T, class Allocator = allocator<T>>
|
| 29 |
class list {
|
| 30 |
public:
|
| 31 |
// types
|
| 32 |
using value_type = T;
|
| 33 |
using allocator_type = Allocator;
|
| 34 |
+
using pointer = allocator_traits<Allocator>::pointer;
|
| 35 |
+
using const_pointer = allocator_traits<Allocator>::const_pointer;
|
| 36 |
using reference = value_type&;
|
| 37 |
using const_reference = const value_type&;
|
| 38 |
using size_type = implementation-defined // type of list::size_type; // see [container.requirements]
|
| 39 |
using difference_type = implementation-defined // type of list::difference_type; // see [container.requirements]
|
| 40 |
using iterator = implementation-defined // type of list::iterator; // see [container.requirements]
|
| 41 |
using const_iterator = implementation-defined // type of list::const_iterator; // see [container.requirements]
|
| 42 |
using reverse_iterator = std::reverse_iterator<iterator>;
|
| 43 |
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
|
| 44 |
|
| 45 |
// [list.cons], construct/copy/destroy
|
| 46 |
+
constexpr list() : list(Allocator()) { }
|
| 47 |
+
constexpr explicit list(const Allocator&);
|
| 48 |
+
constexpr explicit list(size_type n, const Allocator& = Allocator());
|
| 49 |
+
constexpr list(size_type n, const T& value, const Allocator& = Allocator());
|
| 50 |
template<class InputIterator>
|
| 51 |
+
constexpr list(InputIterator first, InputIterator last, const Allocator& = Allocator());
|
| 52 |
template<container-compatible-range<T> R>
|
| 53 |
+
constexpr list(from_range_t, R&& rg, const Allocator& = Allocator());
|
| 54 |
+
constexpr list(const list& x);
|
| 55 |
+
constexpr list(list&& x);
|
| 56 |
+
constexpr list(const list&, const type_identity_t<Allocator>&);
|
| 57 |
+
constexpr list(list&&, const type_identity_t<Allocator>&);
|
| 58 |
+
constexpr list(initializer_list<T>, const Allocator& = Allocator());
|
| 59 |
+
constexpr ~list();
|
| 60 |
+
constexpr list& operator=(const list& x);
|
| 61 |
+
constexpr list& operator=(list&& x)
|
| 62 |
noexcept(allocator_traits<Allocator>::is_always_equal::value);
|
| 63 |
+
constexpr list& operator=(initializer_list<T>);
|
| 64 |
template<class InputIterator>
|
| 65 |
+
constexpr void assign(InputIterator first, InputIterator last);
|
| 66 |
template<container-compatible-range<T> R>
|
| 67 |
+
constexpr void assign_range(R&& rg);
|
| 68 |
+
constexpr void assign(size_type n, const T& t);
|
| 69 |
+
constexpr void assign(initializer_list<T>);
|
| 70 |
+
constexpr allocator_type get_allocator() const noexcept;
|
| 71 |
|
| 72 |
// iterators
|
| 73 |
+
constexpr iterator begin() noexcept;
|
| 74 |
+
constexpr const_iterator begin() const noexcept;
|
| 75 |
+
constexpr iterator end() noexcept;
|
| 76 |
+
constexpr const_iterator end() const noexcept;
|
| 77 |
+
constexpr reverse_iterator rbegin() noexcept;
|
| 78 |
+
constexpr const_reverse_iterator rbegin() const noexcept;
|
| 79 |
+
constexpr reverse_iterator rend() noexcept;
|
| 80 |
+
constexpr const_reverse_iterator rend() const noexcept;
|
| 81 |
|
| 82 |
+
constexpr const_iterator cbegin() const noexcept;
|
| 83 |
+
constexpr const_iterator cend() const noexcept;
|
| 84 |
+
constexpr const_reverse_iterator crbegin() const noexcept;
|
| 85 |
+
constexpr const_reverse_iterator crend() const noexcept;
|
| 86 |
|
| 87 |
// [list.capacity], capacity
|
| 88 |
+
constexpr bool empty() const noexcept;
|
| 89 |
+
constexpr size_type size() const noexcept;
|
| 90 |
+
constexpr size_type max_size() const noexcept;
|
| 91 |
+
constexpr void resize(size_type sz);
|
| 92 |
+
constexpr void resize(size_type sz, const T& c);
|
| 93 |
|
| 94 |
// element access
|
| 95 |
+
constexpr reference front();
|
| 96 |
+
constexpr const_reference front() const;
|
| 97 |
+
constexpr reference back();
|
| 98 |
+
constexpr const_reference back() const;
|
| 99 |
|
| 100 |
// [list.modifiers], modifiers
|
| 101 |
+
template<class... Args> constexpr reference emplace_front(Args&&... args);
|
| 102 |
+
template<class... Args> constexpr reference emplace_back(Args&&... args);
|
| 103 |
+
constexpr void push_front(const T& x);
|
| 104 |
+
constexpr void push_front(T&& x);
|
| 105 |
template<container-compatible-range<T> R>
|
| 106 |
+
constexpr void prepend_range(R&& rg);
|
| 107 |
+
constexpr void pop_front();
|
| 108 |
+
constexpr void push_back(const T& x);
|
| 109 |
+
constexpr void push_back(T&& x);
|
| 110 |
template<container-compatible-range<T> R>
|
| 111 |
+
constexpr void append_range(R&& rg);
|
| 112 |
+
constexpr void pop_back();
|
| 113 |
|
| 114 |
+
template<class... Args> constexpr iterator emplace(const_iterator position, Args&&... args);
|
| 115 |
+
constexpr iterator insert(const_iterator position, const T& x);
|
| 116 |
+
constexpr iterator insert(const_iterator position, T&& x);
|
| 117 |
+
constexpr iterator insert(const_iterator position, size_type n, const T& x);
|
| 118 |
template<class InputIterator>
|
| 119 |
+
constexpr iterator insert(const_iterator position,
|
| 120 |
+
InputIterator first, InputIterator last);
|
| 121 |
template<container-compatible-range<T> R>
|
| 122 |
+
constexpr iterator insert_range(const_iterator position, R&& rg);
|
| 123 |
+
constexpr iterator insert(const_iterator position, initializer_list<T> il);
|
| 124 |
|
| 125 |
+
constexpr iterator erase(const_iterator position);
|
| 126 |
+
constexpr iterator erase(const_iterator position, const_iterator last);
|
| 127 |
+
constexpr void swap(list&) noexcept(allocator_traits<Allocator>::is_always_equal::value);
|
| 128 |
+
constexpr void clear() noexcept;
|
| 129 |
|
| 130 |
// [list.ops], list operations
|
| 131 |
+
constexpr void splice(const_iterator position, list& x);
|
| 132 |
+
constexpr void splice(const_iterator position, list&& x);
|
| 133 |
+
constexpr void splice(const_iterator position, list& x, const_iterator i);
|
| 134 |
+
constexpr void splice(const_iterator position, list&& x, const_iterator i);
|
| 135 |
+
constexpr void splice(const_iterator position, list& x,
|
| 136 |
+
const_iterator first, const_iterator last);
|
| 137 |
+
constexpr void splice(const_iterator position, list&& x,
|
| 138 |
+
const_iterator first, const_iterator last);
|
| 139 |
|
| 140 |
+
constexpr size_type remove(const T& value);
|
| 141 |
+
template<class Predicate> constexpr size_type remove_if(Predicate pred);
|
| 142 |
|
| 143 |
+
constexpr size_type unique();
|
| 144 |
template<class BinaryPredicate>
|
| 145 |
+
constexpr size_type unique(BinaryPredicate binary_pred);
|
| 146 |
|
| 147 |
+
constexpr void merge(list& x);
|
| 148 |
+
constexpr void merge(list&& x);
|
| 149 |
+
template<class Compare> constexpr void merge(list& x, Compare comp);
|
| 150 |
+
template<class Compare> constexpr void merge(list&& x, Compare comp);
|
| 151 |
|
| 152 |
+
constexpr void sort();
|
| 153 |
+
template<class Compare> constexpr void sort(Compare comp);
|
| 154 |
|
| 155 |
+
constexpr void reverse() noexcept;
|
| 156 |
};
|
| 157 |
|
| 158 |
template<class InputIterator, class Allocator = allocator<iter-value-type<InputIterator>>>
|
| 159 |
list(InputIterator, InputIterator, Allocator = Allocator())
|
| 160 |
-> list<iter-value-type<InputIterator>, Allocator>;
|
|
|
|
| 171 |
any member of the resulting specialization of `list` is referenced.
|
| 172 |
|
| 173 |
#### Constructors, copy, and assignment <a id="list.cons">[[list.cons]]</a>
|
| 174 |
|
| 175 |
``` cpp
|
| 176 |
+
constexpr explicit list(const Allocator&);
|
| 177 |
```
|
| 178 |
|
| 179 |
*Effects:* Constructs an empty list, using the specified allocator.
|
| 180 |
|
| 181 |
*Complexity:* Constant.
|
| 182 |
|
| 183 |
``` cpp
|
| 184 |
+
constexpr explicit list(size_type n, const Allocator& = Allocator());
|
| 185 |
```
|
| 186 |
|
| 187 |
+
*Preconditions:* `T` is *Cpp17DefaultInsertable* into `list`.
|
| 188 |
|
| 189 |
*Effects:* Constructs a `list` with `n` default-inserted elements using
|
| 190 |
the specified allocator.
|
| 191 |
|
| 192 |
*Complexity:* Linear in `n`.
|
| 193 |
|
| 194 |
``` cpp
|
| 195 |
+
constexpr list(size_type n, const T& value, const Allocator& = Allocator());
|
| 196 |
```
|
| 197 |
|
| 198 |
+
*Preconditions:* `T` is *Cpp17CopyInsertable* into `list`.
|
| 199 |
|
| 200 |
*Effects:* Constructs a `list` with `n` copies of `value`, using the
|
| 201 |
specified allocator.
|
| 202 |
|
| 203 |
*Complexity:* Linear in `n`.
|
| 204 |
|
| 205 |
``` cpp
|
| 206 |
template<class InputIterator>
|
| 207 |
+
constexpr list(InputIterator first, InputIterator last, const Allocator& = Allocator());
|
| 208 |
```
|
| 209 |
|
| 210 |
*Effects:* Constructs a `list` equal to the range \[`first`, `last`).
|
| 211 |
|
| 212 |
*Complexity:* Linear in `distance(first, last)`.
|
| 213 |
|
| 214 |
``` cpp
|
| 215 |
template<container-compatible-range<T> R>
|
| 216 |
+
constexpr list(from_range_t, R&& rg, const Allocator& = Allocator());
|
| 217 |
```
|
| 218 |
|
| 219 |
*Effects:* Constructs a `list` object with the elements of the range
|
| 220 |
`rg`.
|
| 221 |
|
| 222 |
*Complexity:* Linear in `ranges::distance(rg)`.
|
| 223 |
|
| 224 |
#### Capacity <a id="list.capacity">[[list.capacity]]</a>
|
| 225 |
|
| 226 |
``` cpp
|
| 227 |
+
constexpr void resize(size_type sz);
|
| 228 |
```
|
| 229 |
|
| 230 |
+
*Preconditions:* `T` is *Cpp17DefaultInsertable* into `list`.
|
| 231 |
|
| 232 |
*Effects:* If `size() < sz`, appends `sz - size()` default-inserted
|
| 233 |
elements to the sequence. If `sz <= size()`, equivalent to:
|
| 234 |
|
| 235 |
``` cpp
|
|
|
|
| 237 |
advance(it, sz);
|
| 238 |
erase(it, end());
|
| 239 |
```
|
| 240 |
|
| 241 |
``` cpp
|
| 242 |
+
constexpr void resize(size_type sz, const T& c);
|
| 243 |
```
|
| 244 |
|
| 245 |
+
*Preconditions:* `T` is *Cpp17CopyInsertable* into `list`.
|
| 246 |
|
| 247 |
*Effects:* As if by:
|
| 248 |
|
| 249 |
``` cpp
|
| 250 |
if (sz > size())
|
|
|
|
| 259 |
```
|
| 260 |
|
| 261 |
#### Modifiers <a id="list.modifiers">[[list.modifiers]]</a>
|
| 262 |
|
| 263 |
``` cpp
|
| 264 |
+
constexpr iterator insert(const_iterator position, const T& x);
|
| 265 |
+
constexpr iterator insert(const_iterator position, T&& x);
|
| 266 |
+
constexpr iterator insert(const_iterator position, size_type n, const T& x);
|
| 267 |
template<class InputIterator>
|
| 268 |
+
constexpr iterator insert(const_iterator position,
|
| 269 |
+
InputIterator first, InputIterator last);
|
| 270 |
template<container-compatible-range<T> R>
|
| 271 |
+
constexpr iterator insert_range(const_iterator position, R&& rg);
|
| 272 |
+
constexpr iterator insert(const_iterator position, initializer_list<T>);
|
| 273 |
|
| 274 |
+
template<class... Args> constexpr reference emplace_front(Args&&... args);
|
| 275 |
+
template<class... Args> constexpr reference emplace_back(Args&&... args);
|
| 276 |
+
template<class... Args> constexpr iterator emplace(const_iterator position, Args&&... args);
|
| 277 |
+
constexpr void push_front(const T& x);
|
| 278 |
+
constexpr void push_front(T&& x);
|
| 279 |
template<container-compatible-range<T> R>
|
| 280 |
+
constexpr void prepend_range(R&& rg);
|
| 281 |
+
constexpr void push_back(const T& x);
|
| 282 |
+
constexpr void push_back(T&& x);
|
| 283 |
template<container-compatible-range<T> R>
|
| 284 |
+
constexpr void append_range(R&& rg);
|
| 285 |
```
|
| 286 |
|
| 287 |
*Complexity:* Insertion of a single element into a list takes constant
|
| 288 |
time and exactly one call to a constructor of `T`. Insertion of multiple
|
| 289 |
elements into a list is linear in the number of elements inserted, and
|
| 290 |
the number of calls to the copy constructor or move constructor of `T`
|
| 291 |
is exactly equal to the number of elements inserted.
|
| 292 |
|
| 293 |
*Remarks:* Does not affect the validity of iterators and references. If
|
| 294 |
+
an exception is thrown, there are no effects.
|
| 295 |
|
| 296 |
``` cpp
|
| 297 |
+
constexpr iterator erase(const_iterator position);
|
| 298 |
+
constexpr iterator erase(const_iterator first, const_iterator last);
|
| 299 |
+
constexpr void pop_front();
|
| 300 |
+
constexpr void pop_back();
|
| 301 |
+
constexpr void clear() noexcept;
|
|
|
|
| 302 |
```
|
| 303 |
|
| 304 |
*Effects:* Invalidates only the iterators and references to the erased
|
| 305 |
elements.
|
| 306 |
|
|
|
|
| 327 |
from one list to another. The behavior of splice operations is undefined
|
| 328 |
if `get_allocator() !=
|
| 329 |
x.get_allocator()`.
|
| 330 |
|
| 331 |
``` cpp
|
| 332 |
+
constexpr void splice(const_iterator position, list& x);
|
| 333 |
+
constexpr void splice(const_iterator position, list&& x);
|
| 334 |
```
|
| 335 |
|
| 336 |
*Preconditions:* `addressof(x) != this` is `true`.
|
| 337 |
|
| 338 |
*Effects:* Inserts the contents of `x` before `position` and `x` becomes
|
|
|
|
| 344 |
*Throws:* Nothing.
|
| 345 |
|
| 346 |
*Complexity:* Constant time.
|
| 347 |
|
| 348 |
``` cpp
|
| 349 |
+
constexpr void splice(const_iterator position, list& x, const_iterator i);
|
| 350 |
+
constexpr void splice(const_iterator position, list&& x, const_iterator i);
|
| 351 |
```
|
| 352 |
|
| 353 |
*Preconditions:* `i` is a valid dereferenceable iterator of `x`.
|
| 354 |
|
| 355 |
*Effects:* Inserts an element pointed to by `i` from list `x` before
|
|
|
|
| 362 |
*Throws:* Nothing.
|
| 363 |
|
| 364 |
*Complexity:* Constant time.
|
| 365 |
|
| 366 |
``` cpp
|
| 367 |
+
constexpr void splice(const_iterator position, list& x,
|
| 368 |
+
const_iterator first, const_iterator last);
|
| 369 |
+
constexpr void splice(const_iterator position, list&& x,
|
| 370 |
+
const_iterator first, const_iterator last);
|
| 371 |
```
|
| 372 |
|
| 373 |
+
*Preconditions:* \[`first`, `last`) is a valid range in `x`. `position`
|
| 374 |
+
is not an iterator in the range \[`first`, `last`).
|
| 375 |
|
| 376 |
*Effects:* Inserts elements in the range \[`first`, `last`) before
|
| 377 |
`position` and removes the elements from `x`. Pointers and references to
|
| 378 |
the moved elements of `x` now refer to those same elements but as
|
| 379 |
members of `*this`. Iterators referring to the moved elements will
|
|
|
|
| 384 |
|
| 385 |
*Complexity:* Constant time if `addressof(x) == this`; otherwise, linear
|
| 386 |
time.
|
| 387 |
|
| 388 |
``` cpp
|
| 389 |
+
constexpr size_type remove(const T& value);
|
| 390 |
+
template<class Predicate> constexpr size_type remove_if(Predicate pred);
|
| 391 |
```
|
| 392 |
|
| 393 |
*Effects:* Erases all the elements in the list referred to by a list
|
| 394 |
iterator `i` for which the following conditions hold: `*i == value`,
|
| 395 |
`pred(*i) != false`. Invalidates only the iterators and references to
|
|
|
|
| 404 |
predicate.
|
| 405 |
|
| 406 |
*Remarks:* Stable [[algorithm.stable]].
|
| 407 |
|
| 408 |
``` cpp
|
| 409 |
+
constexpr size_type unique();
|
| 410 |
+
template<class BinaryPredicate> constexpr size_type unique(BinaryPredicate binary_pred);
|
| 411 |
```
|
| 412 |
|
| 413 |
Let `binary_pred` be `equal_to<>{}` for the first overload.
|
| 414 |
|
| 415 |
*Preconditions:* `binary_pred` is an equivalence relation.
|
|
|
|
| 427 |
*Complexity:* If `empty()` is `false`, exactly `size() - 1` applications
|
| 428 |
of the corresponding predicate, otherwise no applications of the
|
| 429 |
predicate.
|
| 430 |
|
| 431 |
``` cpp
|
| 432 |
+
constexpr void merge(list& x);
|
| 433 |
+
constexpr void merge(list&& x);
|
| 434 |
+
template<class Compare> constexpr void merge(list& x, Compare comp);
|
| 435 |
+
template<class Compare> constexpr void merge(list&& x, Compare comp);
|
| 436 |
```
|
| 437 |
|
| 438 |
Let `comp` be `less<>` for the first two overloads.
|
| 439 |
|
| 440 |
*Preconditions:* `*this` and `x` are both sorted with respect to the
|
|
|
|
| 451 |
*Complexity:* At most `size() + x.size() - 1` comparisons if
|
| 452 |
`addressof(x) != this`; otherwise, no comparisons are performed.
|
| 453 |
|
| 454 |
*Remarks:* Stable [[algorithm.stable]]. If `addressof(x) != this`, `x`
|
| 455 |
is empty after the merge. No elements are copied by this operation. If
|
| 456 |
+
an exception is thrown other than by a comparison, there are no effects.
|
| 457 |
|
| 458 |
``` cpp
|
| 459 |
+
constexpr void reverse() noexcept;
|
| 460 |
```
|
| 461 |
|
| 462 |
*Effects:* Reverses the order of the elements in the list. Does not
|
| 463 |
affect the validity of iterators and references.
|
| 464 |
|
|
|
|
| 472 |
*Effects:* Sorts the list according to the `operator<` or a `Compare`
|
| 473 |
function object. If an exception is thrown, the order of the elements in
|
| 474 |
`*this` is unspecified. Does not affect the validity of iterators and
|
| 475 |
references.
|
| 476 |
|
| 477 |
+
*Complexity:* Approximately N log N comparisons, where N is `size()`.
|
| 478 |
|
| 479 |
*Remarks:* Stable [[algorithm.stable]].
|
| 480 |
|
| 481 |
#### Erasure <a id="list.erasure">[[list.erasure]]</a>
|
| 482 |
|
| 483 |
``` cpp
|
| 484 |
+
template<class T, class Allocator, class U = T>
|
| 485 |
typename list<T, Allocator>::size_type
|
| 486 |
+
constexpr erase(list<T, Allocator>& c, const U& value);
|
| 487 |
```
|
| 488 |
|
| 489 |
*Effects:* Equivalent to:
|
| 490 |
+
|
| 491 |
+
``` cpp
|
| 492 |
+
return erase_if(c, [&](const auto& elem) -> bool { return elem == value; });
|
| 493 |
+
```
|
| 494 |
|
| 495 |
``` cpp
|
| 496 |
template<class T, class Allocator, class Predicate>
|
| 497 |
typename list<T, Allocator>::size_type
|
| 498 |
+
constexpr erase_if(list<T, Allocator>& c, Predicate pred);
|
| 499 |
```
|
| 500 |
|
| 501 |
*Effects:* Equivalent to: `return c.remove_if(pred);`
|
| 502 |
|