- tmp/tmp905gizab/{from.md → to.md} +190 -223
tmp/tmp905gizab/{from.md → to.md}
RENAMED
|
@@ -37,15 +37,15 @@ namespace std {
|
|
| 37 |
template <class T, size_t N>
|
| 38 |
struct tuple_size<array<T, N> >;
|
| 39 |
template <size_t I, class T, size_t N>
|
| 40 |
struct tuple_element<I, array<T, N> >;
|
| 41 |
template <size_t I, class T, size_t N>
|
| 42 |
-
T& get(array<T, N>&) noexcept;
|
| 43 |
template <size_t I, class T, size_t N>
|
| 44 |
-
T&& get(array<T, N>&&) noexcept;
|
| 45 |
template <size_t I, class T, size_t N>
|
| 46 |
-
const T& get(const array<T, N>&) noexcept;
|
| 47 |
}
|
| 48 |
```
|
| 49 |
|
| 50 |
\synopsis{Header \texttt{\<deque\>} synopsis}
|
| 51 |
|
|
@@ -144,10 +144,11 @@ namespace std {
|
|
| 144 |
template <class Allocator> class vector<bool,Allocator>;
|
| 145 |
|
| 146 |
// hash support
|
| 147 |
template <class T> struct hash;
|
| 148 |
template <class Allocator> struct hash<vector<bool, Allocator> >;
|
|
|
|
| 149 |
```
|
| 150 |
|
| 151 |
### Class template `array` <a id="array">[[array]]</a>
|
| 152 |
|
| 153 |
#### Class template `array` overview <a id="array.overview">[[array.overview]]</a>
|
|
@@ -190,12 +191,12 @@ namespace std {
|
|
| 190 |
typedef size_t size_type;
|
| 191 |
typedef ptrdiff_t difference_type;
|
| 192 |
typedef T value_type;
|
| 193 |
typedef T* pointer;
|
| 194 |
typedef const T* const_pointer;
|
| 195 |
-
typedef reverse_iterator<iterator>
|
| 196 |
-
typedef reverse_iterator<const_iterator>
|
| 197 |
|
| 198 |
T elems[N]; // exposition only
|
| 199 |
|
| 200 |
// no explicit construct/copy/destroy for aggregate type
|
| 201 |
|
|
@@ -217,23 +218,23 @@ namespace std {
|
|
| 217 |
const_iterator cend() const noexcept;
|
| 218 |
const_reverse_iterator crbegin() const noexcept;
|
| 219 |
const_reverse_iterator crend() const noexcept;
|
| 220 |
|
| 221 |
// capacity:
|
| 222 |
-
constexpr size_type size() noexcept;
|
| 223 |
-
constexpr size_type max_size() noexcept;
|
| 224 |
-
constexpr bool empty() noexcept;
|
| 225 |
|
| 226 |
// element access:
|
| 227 |
reference operator[](size_type n);
|
| 228 |
-
const_reference operator[](size_type n) const;
|
| 229 |
-
const_reference at(size_type n) const;
|
| 230 |
reference at(size_type n);
|
|
|
|
| 231 |
reference front();
|
| 232 |
-
const_reference front() const;
|
| 233 |
reference back();
|
| 234 |
-
const_reference back() const;
|
| 235 |
|
| 236 |
T * data() noexcept;
|
| 237 |
const T * data() const noexcept;
|
| 238 |
};
|
| 239 |
}
|
|
@@ -264,16 +265,16 @@ template <class T, size_t N> void swap(array<T,N>& x, array<T,N>& y) noexcept(no
|
|
| 264 |
|
| 265 |
``` cpp
|
| 266 |
x.swap(y);
|
| 267 |
```
|
| 268 |
|
| 269 |
-
*Complexity:*
|
| 270 |
|
| 271 |
#### `array::size` <a id="array.size">[[array.size]]</a>
|
| 272 |
|
| 273 |
``` cpp
|
| 274 |
-
template <class T, size_t N> constexpr size_type array<T,N>::size() noexcept;
|
| 275 |
```
|
| 276 |
|
| 277 |
*Returns:* `N`
|
| 278 |
|
| 279 |
#### `array::data` <a id="array.data">[[array.data]]</a>
|
|
@@ -302,11 +303,11 @@ void swap(array& y) noexcept(noexcept(swap(declval<T&>(), declval<T&>())));
|
|
| 302 |
*Effects:* `swap_ranges(begin(), end(), y.begin())`
|
| 303 |
|
| 304 |
*Throws:* Nothing unless one of the element-wise swap calls throws an
|
| 305 |
exception.
|
| 306 |
|
| 307 |
-
*Note:* Unlike the `swap` function for other containers, array::swap
|
| 308 |
takes linear time, may exit via an exception, and does not cause
|
| 309 |
iterators to become associated with the other container.
|
| 310 |
|
| 311 |
#### Zero sized arrays <a id="array.zero">[[array.zero]]</a>
|
| 312 |
|
|
@@ -322,42 +323,43 @@ Member function `swap()` shall have a *noexcept-specification* which is
|
|
| 322 |
equivalent to `noexcept(true)`.
|
| 323 |
|
| 324 |
#### Tuple interface to class template `array` <a id="array.tuple">[[array.tuple]]</a>
|
| 325 |
|
| 326 |
``` cpp
|
| 327 |
-
|
|
|
|
|
|
|
| 328 |
```
|
| 329 |
|
| 330 |
-
*Return type:* integral constant expression.
|
| 331 |
-
|
| 332 |
-
*Value:* `N`
|
| 333 |
-
|
| 334 |
``` cpp
|
| 335 |
tuple_element<I, array<T, N> >::type
|
| 336 |
```
|
| 337 |
|
| 338 |
*Requires:* `I < N`. The program is ill-formed if `I` is out of bounds.
|
| 339 |
|
| 340 |
*Value:* The type T.
|
| 341 |
|
| 342 |
``` cpp
|
| 343 |
-
template <size_t I, class T, size_t N>
|
|
|
|
| 344 |
```
|
| 345 |
|
| 346 |
*Requires:* `I < N`. The program is ill-formed if `I` is out of bounds.
|
| 347 |
|
| 348 |
*Returns:* A reference to the `I`th element of `a`, where indexing is
|
| 349 |
zero-based.
|
| 350 |
|
| 351 |
``` cpp
|
| 352 |
-
template <size_t I, class T, size_t N>
|
|
|
|
| 353 |
```
|
| 354 |
|
| 355 |
*Effects:* Equivalent to `return std::move(get<I>(a));`
|
| 356 |
|
| 357 |
``` cpp
|
| 358 |
-
template <size_t I, class T, size_t N>
|
|
|
|
| 359 |
```
|
| 360 |
|
| 361 |
*Requires:* `I < N`. The program is ill-formed if `I` is out of bounds.
|
| 362 |
|
| 363 |
*Returns:* A const reference to the `I`th element of `a`, where indexing
|
|
@@ -401,12 +403,13 @@ namespace std {
|
|
| 401 |
typedef typename allocator_traits<Allocator>::const_pointer const_pointer;
|
| 402 |
typedef std::reverse_iterator<iterator> reverse_iterator;
|
| 403 |
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
| 404 |
|
| 405 |
// [deque.cons], construct/copy/destroy:
|
| 406 |
-
|
| 407 |
-
explicit deque(
|
|
|
|
| 408 |
deque(size_type n, const T& value, const Allocator& = Allocator());
|
| 409 |
template <class InputIterator>
|
| 410 |
deque(InputIterator first, InputIterator last, const Allocator& = Allocator());
|
| 411 |
deque(const deque& x);
|
| 412 |
deque(deque&&);
|
|
@@ -503,24 +506,25 @@ namespace std {
|
|
| 503 |
```
|
| 504 |
|
| 505 |
#### `deque` constructors, copy, and assignment <a id="deque.cons">[[deque.cons]]</a>
|
| 506 |
|
| 507 |
``` cpp
|
| 508 |
-
explicit deque(const Allocator&
|
| 509 |
```
|
| 510 |
|
| 511 |
*Effects:* Constructs an empty `deque`, using the specified allocator.
|
| 512 |
|
| 513 |
*Complexity:* Constant.
|
| 514 |
|
| 515 |
``` cpp
|
| 516 |
-
explicit deque(size_type n);
|
| 517 |
```
|
| 518 |
|
| 519 |
-
*Effects:* Constructs a `deque` with `n`
|
|
|
|
| 520 |
|
| 521 |
-
*Requires:* `T` shall be `
|
| 522 |
|
| 523 |
*Complexity:* Linear in `n`.
|
| 524 |
|
| 525 |
``` cpp
|
| 526 |
deque(size_type n, const T& value,
|
|
@@ -541,71 +545,46 @@ template <class InputIterator>
|
|
| 541 |
```
|
| 542 |
|
| 543 |
*Effects:* Constructs a `deque` equal to the range \[`first`, `last`),
|
| 544 |
using the specified allocator.
|
| 545 |
|
| 546 |
-
*Complexity:* `distance(first, last)`.
|
| 547 |
-
|
| 548 |
-
``` cpp
|
| 549 |
-
template <class InputIterator>
|
| 550 |
-
void assign(InputIterator first, InputIterator last);
|
| 551 |
-
```
|
| 552 |
-
|
| 553 |
-
*Effects:*
|
| 554 |
-
|
| 555 |
-
``` cpp
|
| 556 |
-
erase(begin(), end());
|
| 557 |
-
insert(begin(), first, last);
|
| 558 |
-
```
|
| 559 |
-
|
| 560 |
-
``` cpp
|
| 561 |
-
void assign(size_type n, const T& t);
|
| 562 |
-
```
|
| 563 |
-
|
| 564 |
-
*Effects:*
|
| 565 |
-
|
| 566 |
-
``` cpp
|
| 567 |
-
erase(begin(), end());
|
| 568 |
-
insert(begin(), n, t);
|
| 569 |
-
```
|
| 570 |
|
| 571 |
#### `deque` capacity <a id="deque.capacity">[[deque.capacity]]</a>
|
| 572 |
|
| 573 |
``` cpp
|
| 574 |
void resize(size_type sz);
|
| 575 |
```
|
| 576 |
|
| 577 |
-
*Effects:* If `sz <= size()`, equivalent to
|
| 578 |
-
`
|
| 579 |
-
|
| 580 |
|
| 581 |
-
*Requires:* `T` shall be `
|
|
|
|
| 582 |
|
| 583 |
``` cpp
|
| 584 |
void resize(size_type sz, const T& c);
|
| 585 |
```
|
| 586 |
|
| 587 |
-
*Effects:*
|
| 588 |
-
|
| 589 |
-
``
|
| 590 |
-
if (sz > size())
|
| 591 |
-
insert(end(), sz-size(), c);
|
| 592 |
-
else if (sz < size())
|
| 593 |
-
erase(begin()+sz, end());
|
| 594 |
-
else
|
| 595 |
-
; // do nothing
|
| 596 |
-
```
|
| 597 |
|
| 598 |
*Requires:* `T` shall be `CopyInsertable` into `*this`.
|
| 599 |
|
| 600 |
``` cpp
|
| 601 |
void shrink_to_fit();
|
| 602 |
```
|
| 603 |
|
| 604 |
-
*
|
| 605 |
-
|
| 606 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 607 |
|
| 608 |
#### `deque` modifiers <a id="deque.modifiers">[[deque.modifiers]]</a>
|
| 609 |
|
| 610 |
``` cpp
|
| 611 |
iterator insert(const_iterator position, const T& x);
|
|
@@ -630,12 +609,14 @@ iterators and references to elements of the deque. An insertion at
|
|
| 630 |
either end of the deque invalidates all the iterators to the deque, but
|
| 631 |
has no effect on the validity of references to elements of the deque.
|
| 632 |
|
| 633 |
*Remarks:* If an exception is thrown other than by the copy constructor,
|
| 634 |
move constructor, assignment operator, or move assignment operator of
|
| 635 |
-
`T` there are no effects. If an exception is thrown
|
| 636 |
-
|
|
|
|
|
|
|
| 637 |
|
| 638 |
*Complexity:* The complexity is linear in the number of elements
|
| 639 |
inserted plus the lesser of the distances to the beginning and end of
|
| 640 |
the deque. Inserting a single element either at the beginning or end of
|
| 641 |
a deque always takes constant time and causes a single call to a
|
|
@@ -689,23 +670,23 @@ access to list elements is not supported. It is intended that
|
|
| 689 |
hand-written C-style singly linked list. Features that would conflict
|
| 690 |
with that goal have been omitted.
|
| 691 |
|
| 692 |
A `forward_list` satisfies all of the requirements of a container
|
| 693 |
(Table [[tab:containers.container.requirements]]), except that the
|
| 694 |
-
`size()` member function is not provided
|
| 695 |
-
satisfies all of the requirements for
|
| 696 |
-
(Table [[tab:containers.allocatoraware]]).
|
| 697 |
-
`forward_list` provides the `assign` member functions
|
| 698 |
-
[[tab:containers.sequence.requirements]]) and several of the
|
| 699 |
-
container requirements (Table
|
| 700 |
-
Descriptions are provided here
|
| 701 |
-
|
| 702 |
-
additional semantic information.
|
| 703 |
|
| 704 |
Modifying any list requires access to the element preceding the first
|
| 705 |
element of interest, but in a `forward_list` there is no constant-time
|
| 706 |
-
way to
|
| 707 |
modified, such as those supplied to `erase` and `splice`, must be open
|
| 708 |
at the beginning.
|
| 709 |
|
| 710 |
``` cpp
|
| 711 |
namespace std {
|
|
@@ -723,12 +704,13 @@ namespace std {
|
|
| 723 |
typedef Allocator allocator_type;
|
| 724 |
typedef typename allocator_traits<Allocator>::pointer pointer;
|
| 725 |
typedef typename allocator_traits<Allocator>::const_pointer const_pointer;
|
| 726 |
|
| 727 |
// [forwardlist.cons], construct/copy/destroy:
|
| 728 |
-
|
| 729 |
-
explicit forward_list(
|
|
|
|
| 730 |
forward_list(size_type n, const T& value,
|
| 731 |
const Allocator& = Allocator());
|
| 732 |
template <class InputIterator>
|
| 733 |
forward_list(InputIterator first, InputIterator last,
|
| 734 |
const Allocator& = Allocator());
|
|
@@ -840,26 +822,26 @@ namespace std {
|
|
| 840 |
```
|
| 841 |
|
| 842 |
#### `forward_list` constructors, copy, assignment <a id="forwardlist.cons">[[forwardlist.cons]]</a>
|
| 843 |
|
| 844 |
``` cpp
|
| 845 |
-
explicit forward_list(const Allocator&
|
| 846 |
```
|
| 847 |
|
| 848 |
*Effects:* Constructs an empty `forward_list` object using the specified
|
| 849 |
allocator.
|
| 850 |
|
| 851 |
*Complexity:* Constant.
|
| 852 |
|
| 853 |
``` cpp
|
| 854 |
-
explicit forward_list(size_type n);
|
| 855 |
```
|
| 856 |
|
| 857 |
-
*Effects:* Constructs a `forward_list` object with `n`
|
| 858 |
-
elements.
|
| 859 |
|
| 860 |
-
*Requires:* `T` shall be `
|
| 861 |
|
| 862 |
*Complexity:* Linear in `n`.
|
| 863 |
|
| 864 |
``` cpp
|
| 865 |
forward_list(size_type n, const T& value, const Allocator& = Allocator());
|
|
@@ -880,23 +862,10 @@ template <class InputIterator>
|
|
| 880 |
*Effects:* Constructs a `forward_list` object equal to the range
|
| 881 |
\[`first`, `last`).
|
| 882 |
|
| 883 |
*Complexity:* Linear in `distance(first, last)`.
|
| 884 |
|
| 885 |
-
``` cpp
|
| 886 |
-
template <class InputIterator>
|
| 887 |
-
void assign(InputIterator first, InputIterator last);
|
| 888 |
-
```
|
| 889 |
-
|
| 890 |
-
*Effects:* `clear(); insert_after(before_begin(), first, last);`
|
| 891 |
-
|
| 892 |
-
``` cpp
|
| 893 |
-
void assign(size_type n, const T& t);
|
| 894 |
-
```
|
| 895 |
-
|
| 896 |
-
*Effects:* `clear(); insert_after(before_begin(), n, t);`
|
| 897 |
-
|
| 898 |
#### `forward_list` iterators <a id="forwardlist.iter">[[forwardlist.iter]]</a>
|
| 899 |
|
| 900 |
``` cpp
|
| 901 |
iterator before_begin() noexcept;
|
| 902 |
const_iterator before_begin() const noexcept;
|
|
@@ -995,11 +964,11 @@ iterator insert_after(const_iterator position, initializer_list<T> il);
|
|
| 995 |
```
|
| 996 |
|
| 997 |
*Effects:* `insert_after(p, il.begin(), il.end())`.
|
| 998 |
|
| 999 |
*Returns:* An iterator pointing to the last inserted element or
|
| 1000 |
-
`position` if `
|
| 1001 |
|
| 1002 |
``` cpp
|
| 1003 |
template <class... Args>
|
| 1004 |
iterator emplace_after(const_iterator position, Args&&... args);
|
| 1005 |
```
|
|
@@ -1039,21 +1008,31 @@ dereferenceable.
|
|
| 1039 |
|
| 1040 |
*Throws:* Nothing.
|
| 1041 |
|
| 1042 |
``` cpp
|
| 1043 |
void resize(size_type sz);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1044 |
void resize(size_type sz, const value_type& c);
|
| 1045 |
```
|
| 1046 |
|
| 1047 |
*Effects:* If `sz < distance(begin(), end())`, erases the last
|
| 1048 |
`distance(begin(), end()) - sz` elements from the list. Otherwise,
|
| 1049 |
-
inserts `sz - distance(begin(), end())` elements at the end of the list
|
| 1050 |
-
|
| 1051 |
-
|
|
|
|
| 1052 |
|
| 1053 |
-
*Requires:* `T` shall be `
|
| 1054 |
-
it shall be `CopyInsertable` into `*this` for the second form.
|
| 1055 |
|
| 1056 |
``` cpp
|
| 1057 |
void clear() noexcept;
|
| 1058 |
```
|
| 1059 |
|
|
@@ -1067,11 +1046,12 @@ void clear() noexcept;
|
|
| 1067 |
void splice_after(const_iterator position, forward_list& x);
|
| 1068 |
void splice_after(const_iterator position, forward_list&& x);
|
| 1069 |
```
|
| 1070 |
|
| 1071 |
*Requires:* `position` is `before_begin()` or is a dereferenceable
|
| 1072 |
-
iterator in the range \[`begin()`, `end()`).
|
|
|
|
| 1073 |
|
| 1074 |
*Effects:* Inserts the contents of `x` after `position`, and `x` becomes
|
| 1075 |
empty. Pointers and references to the moved elements of `x` now refer to
|
| 1076 |
those same elements but as members of `*this`. Iterators referring to
|
| 1077 |
the moved elements will continue to refer to their elements, but they
|
|
@@ -1087,17 +1067,18 @@ void splice_after(const_iterator position, forward_list&& x, const_iterator i);
|
|
| 1087 |
```
|
| 1088 |
|
| 1089 |
*Requires:* `position` is `before_begin()` or is a dereferenceable
|
| 1090 |
iterator in the range \[`begin()`, `end()`). The iterator following `i`
|
| 1091 |
is a dereferenceable iterator in `x`.
|
|
|
|
| 1092 |
|
| 1093 |
*Effects:* Inserts the element following `i` into `*this`, following
|
| 1094 |
`position`, and removes it from `x`. The result is unchanged if
|
| 1095 |
-
`position == i` or `position == ++i`. Pointers and references to `*i`
|
| 1096 |
continue to refer to the same element but as a member of `*this`.
|
| 1097 |
-
Iterators to `*i`
|
| 1098 |
-
|
| 1099 |
|
| 1100 |
*Throws:* Nothing.
|
| 1101 |
|
| 1102 |
*Complexity:* 𝑂(1)
|
| 1103 |
|
|
@@ -1110,11 +1091,11 @@ void splice_after(const_iterator position, forward_list&& x,
|
|
| 1110 |
|
| 1111 |
*Requires:* `position` is `before_begin()` or is a dereferenceable
|
| 1112 |
iterator in the range \[`begin()`, `end()`). (`first`, `last`) is a
|
| 1113 |
valid range in `x`, and all iterators in the range (`first`, `last`) are
|
| 1114 |
dereferenceable. `position` is not an iterator in the range (`first`,
|
| 1115 |
-
`last`).
|
| 1116 |
|
| 1117 |
*Effects:* Inserts elements in the range (`first`, `last`) after
|
| 1118 |
`position` and removes the elements from `x`. Pointers and references to
|
| 1119 |
the moved elements of `x` now refer to those same elements but as
|
| 1120 |
members of `*this`. Iterators referring to the moved elements will
|
|
@@ -1128,18 +1109,18 @@ void remove(const T& value);
|
|
| 1128 |
template <class Predicate> void remove_if(Predicate pred);
|
| 1129 |
```
|
| 1130 |
|
| 1131 |
*Effects:* Erases all the elements in the list referred by a list
|
| 1132 |
iterator `i` for which the following conditions hold: `*i == value` (for
|
| 1133 |
-
`remove()`), `pred(*i)` is true (for `remove_if()`).
|
| 1134 |
-
|
| 1135 |
-
is the same as their relative order in the original list. Invalidates
|
| 1136 |
-
only the iterators and references to the erased elements.
|
| 1137 |
|
| 1138 |
*Throws:* Nothing unless an exception is thrown by the equality
|
| 1139 |
comparison or the predicate.
|
| 1140 |
|
|
|
|
|
|
|
| 1141 |
*Complexity:* Exactly `distance(begin(), end())` applications of the
|
| 1142 |
corresponding predicate.
|
| 1143 |
|
| 1144 |
``` cpp
|
| 1145 |
void unique();
|
|
@@ -1161,28 +1142,32 @@ comparison or the predicate.
|
|
| 1161 |
otherwise no applications of the predicate.
|
| 1162 |
|
| 1163 |
``` cpp
|
| 1164 |
void merge(forward_list& x);
|
| 1165 |
void merge(forward_list&& x);
|
| 1166 |
-
template <class Compare> void merge(forward_list& x, Compare comp)
|
| 1167 |
-
template <class Compare> void merge(forward_list&& x, Compare comp)
|
| 1168 |
```
|
| 1169 |
|
| 1170 |
*Requires:* `comp` defines a strict weak ordering ([[alg.sorting]]),
|
| 1171 |
and `*this` and `x` are both sorted according to this ordering.
|
|
|
|
| 1172 |
|
| 1173 |
-
*Effects:* Merges
|
| 1174 |
-
|
| 1175 |
-
|
| 1176 |
-
|
| 1177 |
-
|
| 1178 |
-
|
| 1179 |
-
|
| 1180 |
-
behave as iterators into `*this`, not into `x`.
|
| 1181 |
|
| 1182 |
-
*
|
| 1183 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1184 |
|
| 1185 |
``` cpp
|
| 1186 |
void sort();
|
| 1187 |
template <class Compare> void sort(Compare comp);
|
| 1188 |
```
|
|
@@ -1190,14 +1175,15 @@ template <class Compare> void sort(Compare comp);
|
|
| 1190 |
*Requires:* `operator<` (for the version with no arguments) or `comp`
|
| 1191 |
(for the version with a comparison argument) defines a strict weak
|
| 1192 |
ordering ([[alg.sorting]]).
|
| 1193 |
|
| 1194 |
*Effects:* Sorts the list according to the `operator<` or the `comp`
|
| 1195 |
-
function object.
|
| 1196 |
-
|
| 1197 |
-
|
| 1198 |
-
|
|
|
|
| 1199 |
|
| 1200 |
*Complexity:* Approximately N log N comparisons, where N is
|
| 1201 |
`distance(begin(), end())`.
|
| 1202 |
|
| 1203 |
``` cpp
|
|
@@ -1258,12 +1244,13 @@ namespace std {
|
|
| 1258 |
typedef typename allocator_traits<Allocator>::const_pointer const_pointer;
|
| 1259 |
typedef std::reverse_iterator<iterator> reverse_iterator;
|
| 1260 |
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
| 1261 |
|
| 1262 |
// [list.cons], construct/copy/destroy:
|
| 1263 |
-
|
| 1264 |
-
explicit list(
|
|
|
|
| 1265 |
list(size_type n, const T& value, const Allocator& = Allocator());
|
| 1266 |
template <class InputIterator>
|
| 1267 |
list(InputIterator first, InputIterator last, const Allocator& = Allocator());
|
| 1268 |
list(const list& x);
|
| 1269 |
list(list&& x);
|
|
@@ -1380,24 +1367,25 @@ namespace std {
|
|
| 1380 |
```
|
| 1381 |
|
| 1382 |
#### `list` constructors, copy, and assignment <a id="list.cons">[[list.cons]]</a>
|
| 1383 |
|
| 1384 |
``` cpp
|
| 1385 |
-
explicit list(const Allocator&
|
| 1386 |
```
|
| 1387 |
|
| 1388 |
*Effects:* Constructs an empty list, using the specified allocator.
|
| 1389 |
|
| 1390 |
*Complexity:* Constant.
|
| 1391 |
|
| 1392 |
``` cpp
|
| 1393 |
-
explicit list(size_type n);
|
| 1394 |
```
|
| 1395 |
|
| 1396 |
-
*Effects:* Constructs a `list` with `n`
|
|
|
|
| 1397 |
|
| 1398 |
-
*Requires:* `T` shall be `
|
| 1399 |
|
| 1400 |
*Complexity:* Linear in `n`.
|
| 1401 |
|
| 1402 |
``` cpp
|
| 1403 |
list(size_type n, const T& value,
|
|
@@ -1419,40 +1407,26 @@ list(InputIterator first, InputIterator last,
|
|
| 1419 |
|
| 1420 |
*Effects:* Constructs a `list` equal to the range \[`first`, `last`).
|
| 1421 |
|
| 1422 |
*Complexity:* Linear in `distance(first, last)`.
|
| 1423 |
|
| 1424 |
-
``` cpp
|
| 1425 |
-
template <class InputIterator>
|
| 1426 |
-
void assign(InputIterator first, InputIterator last);
|
| 1427 |
-
```
|
| 1428 |
-
|
| 1429 |
-
*Effects:* Replaces the contents of the list with the range
|
| 1430 |
-
`[first, last)`.
|
| 1431 |
-
|
| 1432 |
-
``` cpp
|
| 1433 |
-
void assign(size_type n, const T& t);
|
| 1434 |
-
```
|
| 1435 |
-
|
| 1436 |
-
*Effects:* Replaces the contents of the list with `n` copies of `t`.
|
| 1437 |
-
|
| 1438 |
#### `list` capacity <a id="list.capacity">[[list.capacity]]</a>
|
| 1439 |
|
| 1440 |
``` cpp
|
| 1441 |
void resize(size_type sz);
|
| 1442 |
```
|
| 1443 |
|
| 1444 |
-
*Effects:* If `size() < sz`, appends `sz - size()`
|
| 1445 |
elements to the sequence. If `sz <= size()`, equivalent to
|
| 1446 |
|
| 1447 |
``` cpp
|
| 1448 |
list<T>::iterator it = begin();
|
| 1449 |
advance(it, sz);
|
| 1450 |
erase(it, end());
|
| 1451 |
```
|
| 1452 |
|
| 1453 |
-
*Requires:* `T` shall be `
|
| 1454 |
|
| 1455 |
``` cpp
|
| 1456 |
void resize(size_type sz, const T& c);
|
| 1457 |
```
|
| 1458 |
|
|
@@ -1597,11 +1571,11 @@ iterator `i` for which the following conditions hold:
|
|
| 1597 |
references to the erased elements.
|
| 1598 |
|
| 1599 |
*Throws:* Nothing unless an exception is thrown by `*i == value` or
|
| 1600 |
`pred(*i) != false`.
|
| 1601 |
|
| 1602 |
-
*Remarks:* Stable.
|
| 1603 |
|
| 1604 |
*Complexity:* Exactly `size()` applications of the corresponding
|
| 1605 |
predicate.
|
| 1606 |
|
| 1607 |
``` cpp
|
|
@@ -1614,11 +1588,11 @@ of equal elements referred to by the iterator `i` in the range
|
|
| 1614 |
\[`first + 1`, `last`) for which `*i == *(i-1)` (for the version of
|
| 1615 |
`unique` with no arguments) or `pred(*i, *(i - 1))` (for the version of
|
| 1616 |
`unique` with a predicate argument) holds. Invalidates only the
|
| 1617 |
iterators and references to the erased elements.
|
| 1618 |
|
| 1619 |
-
*Throws:* Nothing unless an exception
|
| 1620 |
`pred(*i, *(i - 1))`
|
| 1621 |
|
| 1622 |
*Complexity:* If the range `[first, last)` is not empty, exactly
|
| 1623 |
`(last - first) - 1` applications of the corresponding predicate,
|
| 1624 |
otherwise no applications of the predicate.
|
|
@@ -1643,13 +1617,14 @@ according to the ordering defined by `comp`; that is, for every iterator
|
|
| 1643 |
elements of `x` now refer to those same elements but as members of
|
| 1644 |
`*this`. Iterators referring to the moved elements will continue to
|
| 1645 |
refer to their elements, but they now behave as iterators into `*this`,
|
| 1646 |
not into `x`.
|
| 1647 |
|
| 1648 |
-
*Remarks:* Stable. If `(&x != this)` the range
|
| 1649 |
-
empty after the merge. No elements are copied
|
| 1650 |
-
behavior is undefined if
|
|
|
|
| 1651 |
|
| 1652 |
*Complexity:* At most `size() + x.size() - 1` applications of `comp` if
|
| 1653 |
`(&x != this)`; otherwise, no applications of `comp` are performed. If
|
| 1654 |
an exception is thrown other than by a comparison there are no effects.
|
| 1655 |
|
|
@@ -1672,11 +1647,11 @@ second version) shall define a strict weak ordering ([[alg.sorting]]).
|
|
| 1672 |
|
| 1673 |
*Effects:* Sorts the list according to the `operator<` or a `Compare`
|
| 1674 |
function object. Does not affect the validity of iterators and
|
| 1675 |
references.
|
| 1676 |
|
| 1677 |
-
*Remarks:* Stable.
|
| 1678 |
|
| 1679 |
*Complexity:* Approximately N log(N) comparisons, where `N == size()`.
|
| 1680 |
|
| 1681 |
#### `list` specialized algorithms <a id="list.special">[[list.special]]</a>
|
| 1682 |
|
|
@@ -1733,12 +1708,13 @@ namespace std {
|
|
| 1733 |
typedef typename allocator_traits<Allocator>::const_pointer const_pointer;
|
| 1734 |
typedef std::reverse_iterator<iterator> reverse_iterator;
|
| 1735 |
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
| 1736 |
|
| 1737 |
// [vector.cons], construct/copy/destroy:
|
| 1738 |
-
|
| 1739 |
-
explicit vector(
|
|
|
|
| 1740 |
vector(size_type n, const T& value, const Allocator& = Allocator());
|
| 1741 |
template <class InputIterator>
|
| 1742 |
vector(InputIterator first, InputIterator last,
|
| 1743 |
const Allocator& = Allocator());
|
| 1744 |
vector(const vector& x);
|
|
@@ -1835,24 +1811,25 @@ namespace std {
|
|
| 1835 |
```
|
| 1836 |
|
| 1837 |
#### `vector` constructors, copy, and assignment <a id="vector.cons">[[vector.cons]]</a>
|
| 1838 |
|
| 1839 |
``` cpp
|
| 1840 |
-
explicit vector(const Allocator&
|
| 1841 |
```
|
| 1842 |
|
| 1843 |
*Effects:* Constructs an empty `vector`, using the specified allocator.
|
| 1844 |
|
| 1845 |
*Complexity:* Constant.
|
| 1846 |
|
| 1847 |
``` cpp
|
| 1848 |
-
explicit vector(size_type n);
|
| 1849 |
```
|
| 1850 |
|
| 1851 |
-
*Effects:* Constructs a `vector` with `n`
|
|
|
|
| 1852 |
|
| 1853 |
-
*Requires:* `T` shall be `
|
| 1854 |
|
| 1855 |
*Complexity:* Linear in `n`.
|
| 1856 |
|
| 1857 |
``` cpp
|
| 1858 |
vector(size_type n, const T& value,
|
|
@@ -1879,33 +1856,10 @@ using the specified allocator.
|
|
| 1879 |
is the distance between `first` and `last`) and no reallocations if
|
| 1880 |
iterators first and last are of forward, bidirectional, or random access
|
| 1881 |
categories. It makes order `N` calls to the copy constructor of `T` and
|
| 1882 |
order log(N) reallocations if they are just input iterators.
|
| 1883 |
|
| 1884 |
-
``` cpp
|
| 1885 |
-
template <class InputIterator>
|
| 1886 |
-
void assign(InputIterator first, InputIterator last);
|
| 1887 |
-
```
|
| 1888 |
-
|
| 1889 |
-
*Effects:*
|
| 1890 |
-
|
| 1891 |
-
``` cpp
|
| 1892 |
-
erase(begin(), end());
|
| 1893 |
-
insert(begin(), first, last);
|
| 1894 |
-
```
|
| 1895 |
-
|
| 1896 |
-
``` cpp
|
| 1897 |
-
void assign(size_type n, const T& t);
|
| 1898 |
-
```
|
| 1899 |
-
|
| 1900 |
-
*Effects:*
|
| 1901 |
-
|
| 1902 |
-
``` cpp
|
| 1903 |
-
erase(begin(), end());
|
| 1904 |
-
insert(begin(), n, t);
|
| 1905 |
-
```
|
| 1906 |
-
|
| 1907 |
#### `vector` capacity <a id="vector.capacity">[[vector.capacity]]</a>
|
| 1908 |
|
| 1909 |
``` cpp
|
| 1910 |
size_type capacity() const noexcept;
|
| 1911 |
```
|
|
@@ -1915,10 +1869,12 @@ requiring reallocation.
|
|
| 1915 |
|
| 1916 |
``` cpp
|
| 1917 |
void reserve(size_type n);
|
| 1918 |
```
|
| 1919 |
|
|
|
|
|
|
|
| 1920 |
*Effects:* A directive that informs a `vector` of a planned change in
|
| 1921 |
size, so that it can manage the storage allocation accordingly. After
|
| 1922 |
`reserve()`, `capacity()` is greater or equal to the argument of
|
| 1923 |
`reserve` if reallocation happens; and equal to the previous value of
|
| 1924 |
`capacity()` otherwise. Reallocation happens at this point if and only
|
|
@@ -1930,22 +1886,28 @@ non-`CopyInsertable` type, there are no effects.
|
|
| 1930 |
most linear time in the size of the sequence.
|
| 1931 |
|
| 1932 |
*Throws:* `length_error` if `n > max_size()`.[^4]
|
| 1933 |
|
| 1934 |
*Remarks:* Reallocation invalidates all the references, pointers, and
|
| 1935 |
-
iterators referring to the elements in the sequence.
|
| 1936 |
-
|
| 1937 |
-
|
| 1938 |
-
|
| 1939 |
|
| 1940 |
``` cpp
|
| 1941 |
void shrink_to_fit();
|
| 1942 |
```
|
| 1943 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1944 |
*Remarks:* `shrink_to_fit` is a non-binding request to reduce
|
| 1945 |
`capacity()` to `size()`. The request is non-binding to allow latitude
|
| 1946 |
-
for implementation-specific optimizations.
|
|
|
|
|
|
|
| 1947 |
|
| 1948 |
``` cpp
|
| 1949 |
void swap(vector& x);
|
| 1950 |
```
|
| 1951 |
|
|
@@ -1956,34 +1918,32 @@ of `x`.
|
|
| 1956 |
|
| 1957 |
``` cpp
|
| 1958 |
void resize(size_type sz);
|
| 1959 |
```
|
| 1960 |
|
| 1961 |
-
*Effects:* If `sz <= size()`, equivalent to
|
| 1962 |
-
`
|
| 1963 |
-
|
| 1964 |
|
| 1965 |
-
*Requires:* `T` shall be `
|
|
|
|
| 1966 |
|
| 1967 |
-
|
| 1968 |
-
void resize(size_type sz, const T& c);
|
| 1969 |
-
```
|
| 1970 |
-
|
| 1971 |
-
*Effects:*
|
| 1972 |
-
|
| 1973 |
-
``` cpp
|
| 1974 |
-
if (sz > size())
|
| 1975 |
-
insert(end(), sz-size(), c);
|
| 1976 |
-
else if (sz < size())
|
| 1977 |
-
erase(begin()+sz, end());
|
| 1978 |
-
else
|
| 1979 |
-
; // do nothing
|
| 1980 |
-
```
|
| 1981 |
-
|
| 1982 |
-
*Requires:* If an exception is thrown other than by the move constructor
|
| 1983 |
of a non-`CopyInsertable` `T` there are no effects.
|
| 1984 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1985 |
#### `vector` data <a id="vector.data">[[vector.data]]</a>
|
| 1986 |
|
| 1987 |
``` cpp
|
| 1988 |
T* data() noexcept;
|
| 1989 |
const T* data() const noexcept;
|
|
@@ -2013,12 +1973,15 @@ void push_back(T&& x);
|
|
| 2013 |
*Remarks:* Causes reallocation if the new size is greater than the old
|
| 2014 |
capacity. If no reallocation happens, all the iterators and references
|
| 2015 |
before the insertion point remain valid. If an exception is thrown other
|
| 2016 |
than by the copy constructor, move constructor, assignment operator, or
|
| 2017 |
move assignment operator of `T` or by any `InputIterator` operation
|
| 2018 |
-
there are no effects. If an exception is thrown
|
| 2019 |
-
|
|
|
|
|
|
|
|
|
|
| 2020 |
|
| 2021 |
*Complexity:* The complexity is linear in the number of elements
|
| 2022 |
inserted plus the distance to the end of the vector.
|
| 2023 |
|
| 2024 |
``` cpp
|
|
@@ -2084,12 +2047,14 @@ namespace std {
|
|
| 2084 |
reference& operator=(const reference& x) noexcept;
|
| 2085 |
void flip() noexcept; // flips the bit
|
| 2086 |
};
|
| 2087 |
|
| 2088 |
// construct/copy/destroy:
|
| 2089 |
-
|
| 2090 |
-
explicit vector(
|
|
|
|
|
|
|
| 2091 |
const Allocator& = Allocator());
|
| 2092 |
template <class InputIterator>
|
| 2093 |
vector(InputIterator first, InputIterator last,
|
| 2094 |
const Allocator& = Allocator());
|
| 2095 |
vector(const vector<bool,Allocator>& x);
|
|
@@ -2098,15 +2063,15 @@ namespace std {
|
|
| 2098 |
vector(vector&&, const Allocator&);
|
| 2099 |
vector(initializer_list<bool>, const Allocator& = Allocator()));
|
| 2100 |
~vector();
|
| 2101 |
vector<bool,Allocator>& operator=(const vector<bool,Allocator>& x);
|
| 2102 |
vector<bool,Allocator>& operator=(vector<bool,Allocator>&& x);
|
| 2103 |
-
vector operator=(initializer_list<bool>);
|
| 2104 |
template <class InputIterator>
|
| 2105 |
void assign(InputIterator first, InputIterator last);
|
| 2106 |
void assign(size_type n, const bool& t);
|
| 2107 |
-
void assign(initializer_list<bool>;
|
| 2108 |
allocator_type get_allocator() const noexcept;
|
| 2109 |
|
| 2110 |
// iterators:
|
| 2111 |
iterator begin() noexcept;
|
| 2112 |
const_iterator begin() const noexcept;
|
|
@@ -2140,12 +2105,14 @@ namespace std {
|
|
| 2140 |
const_reference front() const;
|
| 2141 |
reference back();
|
| 2142 |
const_reference back() const;
|
| 2143 |
|
| 2144 |
// modifiers:
|
|
|
|
| 2145 |
void push_back(const bool& x);
|
| 2146 |
void pop_back();
|
|
|
|
| 2147 |
iterator insert(const_iterator position, const bool& x);
|
| 2148 |
iterator insert (const_iterator position, size_type n, const bool& x);
|
| 2149 |
template <class InputIterator>
|
| 2150 |
iterator insert(const_iterator position,
|
| 2151 |
InputIterator first, InputIterator last);
|
|
@@ -2199,8 +2166,8 @@ y = b;
|
|
| 2199 |
|
| 2200 |
``` cpp
|
| 2201 |
template <class Allocator> struct hash<vector<bool, Allocator> >;
|
| 2202 |
```
|
| 2203 |
|
| 2204 |
-
|
| 2205 |
-
|
| 2206 |
|
|
|
|
| 37 |
template <class T, size_t N>
|
| 38 |
struct tuple_size<array<T, N> >;
|
| 39 |
template <size_t I, class T, size_t N>
|
| 40 |
struct tuple_element<I, array<T, N> >;
|
| 41 |
template <size_t I, class T, size_t N>
|
| 42 |
+
constexpr T& get(array<T, N>&) noexcept;
|
| 43 |
template <size_t I, class T, size_t N>
|
| 44 |
+
constexpr T&& get(array<T, N>&&) noexcept;
|
| 45 |
template <size_t I, class T, size_t N>
|
| 46 |
+
constexpr const T& get(const array<T, N>&) noexcept;
|
| 47 |
}
|
| 48 |
```
|
| 49 |
|
| 50 |
\synopsis{Header \texttt{\<deque\>} synopsis}
|
| 51 |
|
|
|
|
| 144 |
template <class Allocator> class vector<bool,Allocator>;
|
| 145 |
|
| 146 |
// hash support
|
| 147 |
template <class T> struct hash;
|
| 148 |
template <class Allocator> struct hash<vector<bool, Allocator> >;
|
| 149 |
+
}
|
| 150 |
```
|
| 151 |
|
| 152 |
### Class template `array` <a id="array">[[array]]</a>
|
| 153 |
|
| 154 |
#### Class template `array` overview <a id="array.overview">[[array.overview]]</a>
|
|
|
|
| 191 |
typedef size_t size_type;
|
| 192 |
typedef ptrdiff_t difference_type;
|
| 193 |
typedef T value_type;
|
| 194 |
typedef T* pointer;
|
| 195 |
typedef const T* const_pointer;
|
| 196 |
+
typedef std::reverse_iterator<iterator> reverse_iterator;
|
| 197 |
+
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
| 198 |
|
| 199 |
T elems[N]; // exposition only
|
| 200 |
|
| 201 |
// no explicit construct/copy/destroy for aggregate type
|
| 202 |
|
|
|
|
| 218 |
const_iterator cend() const noexcept;
|
| 219 |
const_reverse_iterator crbegin() const noexcept;
|
| 220 |
const_reverse_iterator crend() const noexcept;
|
| 221 |
|
| 222 |
// capacity:
|
| 223 |
+
constexpr size_type size() const noexcept;
|
| 224 |
+
constexpr size_type max_size() const noexcept;
|
| 225 |
+
constexpr bool empty() const noexcept;
|
| 226 |
|
| 227 |
// element access:
|
| 228 |
reference operator[](size_type n);
|
| 229 |
+
constexpr const_reference operator[](size_type n) const;
|
|
|
|
| 230 |
reference at(size_type n);
|
| 231 |
+
constexpr const_reference at(size_type n) const;
|
| 232 |
reference front();
|
| 233 |
+
constexpr const_reference front() const;
|
| 234 |
reference back();
|
| 235 |
+
constexpr const_reference back() const;
|
| 236 |
|
| 237 |
T * data() noexcept;
|
| 238 |
const T * data() const noexcept;
|
| 239 |
};
|
| 240 |
}
|
|
|
|
| 265 |
|
| 266 |
``` cpp
|
| 267 |
x.swap(y);
|
| 268 |
```
|
| 269 |
|
| 270 |
+
*Complexity:* Linear in `N`.
|
| 271 |
|
| 272 |
#### `array::size` <a id="array.size">[[array.size]]</a>
|
| 273 |
|
| 274 |
``` cpp
|
| 275 |
+
template <class T, size_t N> constexpr size_type array<T,N>::size() const noexcept;
|
| 276 |
```
|
| 277 |
|
| 278 |
*Returns:* `N`
|
| 279 |
|
| 280 |
#### `array::data` <a id="array.data">[[array.data]]</a>
|
|
|
|
| 303 |
*Effects:* `swap_ranges(begin(), end(), y.begin())`
|
| 304 |
|
| 305 |
*Throws:* Nothing unless one of the element-wise swap calls throws an
|
| 306 |
exception.
|
| 307 |
|
| 308 |
+
*Note:* Unlike the `swap` function for other containers, `array::swap`
|
| 309 |
takes linear time, may exit via an exception, and does not cause
|
| 310 |
iterators to become associated with the other container.
|
| 311 |
|
| 312 |
#### Zero sized arrays <a id="array.zero">[[array.zero]]</a>
|
| 313 |
|
|
|
|
| 323 |
equivalent to `noexcept(true)`.
|
| 324 |
|
| 325 |
#### Tuple interface to class template `array` <a id="array.tuple">[[array.tuple]]</a>
|
| 326 |
|
| 327 |
``` cpp
|
| 328 |
+
template <class T, size_t N>
|
| 329 |
+
struct tuple_size<array<T, N>>
|
| 330 |
+
: integral_constant<size_t, N> { };
|
| 331 |
```
|
| 332 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 333 |
``` cpp
|
| 334 |
tuple_element<I, array<T, N> >::type
|
| 335 |
```
|
| 336 |
|
| 337 |
*Requires:* `I < N`. The program is ill-formed if `I` is out of bounds.
|
| 338 |
|
| 339 |
*Value:* The type T.
|
| 340 |
|
| 341 |
``` cpp
|
| 342 |
+
template <size_t I, class T, size_t N>
|
| 343 |
+
constexpr T& get(array<T, N>& a) noexcept;
|
| 344 |
```
|
| 345 |
|
| 346 |
*Requires:* `I < N`. The program is ill-formed if `I` is out of bounds.
|
| 347 |
|
| 348 |
*Returns:* A reference to the `I`th element of `a`, where indexing is
|
| 349 |
zero-based.
|
| 350 |
|
| 351 |
``` cpp
|
| 352 |
+
template <size_t I, class T, size_t N>
|
| 353 |
+
constexpr T&& get(array<T, N>&& a) noexcept;
|
| 354 |
```
|
| 355 |
|
| 356 |
*Effects:* Equivalent to `return std::move(get<I>(a));`
|
| 357 |
|
| 358 |
``` cpp
|
| 359 |
+
template <size_t I, class T, size_t N>
|
| 360 |
+
constexpr const T& get(const array<T, N>& a) noexcept;
|
| 361 |
```
|
| 362 |
|
| 363 |
*Requires:* `I < N`. The program is ill-formed if `I` is out of bounds.
|
| 364 |
|
| 365 |
*Returns:* A const reference to the `I`th element of `a`, where indexing
|
|
|
|
| 403 |
typedef typename allocator_traits<Allocator>::const_pointer const_pointer;
|
| 404 |
typedef std::reverse_iterator<iterator> reverse_iterator;
|
| 405 |
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
| 406 |
|
| 407 |
// [deque.cons], construct/copy/destroy:
|
| 408 |
+
deque() : deque(Allocator()) { }
|
| 409 |
+
explicit deque(const Allocator&);
|
| 410 |
+
explicit deque(size_type n, const Allocator& = Allocator());
|
| 411 |
deque(size_type n, const T& value, const Allocator& = Allocator());
|
| 412 |
template <class InputIterator>
|
| 413 |
deque(InputIterator first, InputIterator last, const Allocator& = Allocator());
|
| 414 |
deque(const deque& x);
|
| 415 |
deque(deque&&);
|
|
|
|
| 506 |
```
|
| 507 |
|
| 508 |
#### `deque` constructors, copy, and assignment <a id="deque.cons">[[deque.cons]]</a>
|
| 509 |
|
| 510 |
``` cpp
|
| 511 |
+
explicit deque(const Allocator&);
|
| 512 |
```
|
| 513 |
|
| 514 |
*Effects:* Constructs an empty `deque`, using the specified allocator.
|
| 515 |
|
| 516 |
*Complexity:* Constant.
|
| 517 |
|
| 518 |
``` cpp
|
| 519 |
+
explicit deque(size_type n, const Allocator& = Allocator());
|
| 520 |
```
|
| 521 |
|
| 522 |
+
*Effects:* Constructs a `deque` with `n` default-inserted elements using
|
| 523 |
+
the specified allocator.
|
| 524 |
|
| 525 |
+
*Requires:* `T` shall be `DefaultInsertable` into `*this`.
|
| 526 |
|
| 527 |
*Complexity:* Linear in `n`.
|
| 528 |
|
| 529 |
``` cpp
|
| 530 |
deque(size_type n, const T& value,
|
|
|
|
| 545 |
```
|
| 546 |
|
| 547 |
*Effects:* Constructs a `deque` equal to the range \[`first`, `last`),
|
| 548 |
using the specified allocator.
|
| 549 |
|
| 550 |
+
*Complexity:* Linear in `distance(first, last)`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 551 |
|
| 552 |
#### `deque` capacity <a id="deque.capacity">[[deque.capacity]]</a>
|
| 553 |
|
| 554 |
``` cpp
|
| 555 |
void resize(size_type sz);
|
| 556 |
```
|
| 557 |
|
| 558 |
+
*Effects:* If `sz <= size()`, equivalent to calling `pop_back()`
|
| 559 |
+
`size() - sz` times. If `size() < sz`, appends `sz - size()`
|
| 560 |
+
default-inserted elements to the sequence.
|
| 561 |
|
| 562 |
+
*Requires:* `T` shall be `MoveInsertable` and `DefaultInsertable` into
|
| 563 |
+
`*this`.
|
| 564 |
|
| 565 |
``` cpp
|
| 566 |
void resize(size_type sz, const T& c);
|
| 567 |
```
|
| 568 |
|
| 569 |
+
*Effects:* If `sz <= size()`, equivalent to calling `pop_back()`
|
| 570 |
+
`size() - sz` times. If `size() < sz`, appends `sz - size()` copies of
|
| 571 |
+
`c` to the sequence.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 572 |
|
| 573 |
*Requires:* `T` shall be `CopyInsertable` into `*this`.
|
| 574 |
|
| 575 |
``` cpp
|
| 576 |
void shrink_to_fit();
|
| 577 |
```
|
| 578 |
|
| 579 |
+
*Requires:* `T` shall be `MoveInsertable` into `*this`.
|
| 580 |
+
|
| 581 |
+
*Complexity:* Linear in the size of the sequence.
|
| 582 |
+
|
| 583 |
+
*Remarks:* `shrink_to_fit` is a non-binding request to reduce memory use
|
| 584 |
+
but does not change the size of the sequence. The request is non-binding
|
| 585 |
+
to allow latitude for implementation-specific optimizations.
|
| 586 |
|
| 587 |
#### `deque` modifiers <a id="deque.modifiers">[[deque.modifiers]]</a>
|
| 588 |
|
| 589 |
``` cpp
|
| 590 |
iterator insert(const_iterator position, const T& x);
|
|
|
|
| 609 |
either end of the deque invalidates all the iterators to the deque, but
|
| 610 |
has no effect on the validity of references to elements of the deque.
|
| 611 |
|
| 612 |
*Remarks:* If an exception is thrown other than by the copy constructor,
|
| 613 |
move constructor, assignment operator, or move assignment operator of
|
| 614 |
+
`T` there are no effects. If an exception is thrown while inserting a
|
| 615 |
+
single element at either end, there are no effects. Otherwise, if an
|
| 616 |
+
exception is thrown by the move constructor of a non-`CopyInsertable`
|
| 617 |
+
`T`, the effects are unspecified.
|
| 618 |
|
| 619 |
*Complexity:* The complexity is linear in the number of elements
|
| 620 |
inserted plus the lesser of the distances to the beginning and end of
|
| 621 |
the deque. Inserting a single element either at the beginning or end of
|
| 622 |
a deque always takes constant time and causes a single call to a
|
|
|
|
| 670 |
hand-written C-style singly linked list. Features that would conflict
|
| 671 |
with that goal have been omitted.
|
| 672 |
|
| 673 |
A `forward_list` satisfies all of the requirements of a container
|
| 674 |
(Table [[tab:containers.container.requirements]]), except that the
|
| 675 |
+
`size()` member function is not provided and `operator==` has linear
|
| 676 |
+
complexity. A `forward_list` also satisfies all of the requirements for
|
| 677 |
+
an allocator-aware container (Table [[tab:containers.allocatoraware]]).
|
| 678 |
+
In addition, a `forward_list` provides the `assign` member functions
|
| 679 |
+
(Table [[tab:containers.sequence.requirements]]) and several of the
|
| 680 |
+
optional container requirements (Table
|
| 681 |
+
[[tab:containers.sequence.optional]]). Descriptions are provided here
|
| 682 |
+
only for operations on `forward_list` that are not described in that
|
| 683 |
+
table or for operations where there is additional semantic information.
|
| 684 |
|
| 685 |
Modifying any list requires access to the element preceding the first
|
| 686 |
element of interest, but in a `forward_list` there is no constant-time
|
| 687 |
+
way to access a preceding element. For this reason, ranges that are
|
| 688 |
modified, such as those supplied to `erase` and `splice`, must be open
|
| 689 |
at the beginning.
|
| 690 |
|
| 691 |
``` cpp
|
| 692 |
namespace std {
|
|
|
|
| 704 |
typedef Allocator allocator_type;
|
| 705 |
typedef typename allocator_traits<Allocator>::pointer pointer;
|
| 706 |
typedef typename allocator_traits<Allocator>::const_pointer const_pointer;
|
| 707 |
|
| 708 |
// [forwardlist.cons], construct/copy/destroy:
|
| 709 |
+
forward_list() : forward_list(Allocator()) { }
|
| 710 |
+
explicit forward_list(const Allocator&);
|
| 711 |
+
explicit forward_list(size_type n, const Allocator& = Allocator());
|
| 712 |
forward_list(size_type n, const T& value,
|
| 713 |
const Allocator& = Allocator());
|
| 714 |
template <class InputIterator>
|
| 715 |
forward_list(InputIterator first, InputIterator last,
|
| 716 |
const Allocator& = Allocator());
|
|
|
|
| 822 |
```
|
| 823 |
|
| 824 |
#### `forward_list` constructors, copy, assignment <a id="forwardlist.cons">[[forwardlist.cons]]</a>
|
| 825 |
|
| 826 |
``` cpp
|
| 827 |
+
explicit forward_list(const Allocator&);
|
| 828 |
```
|
| 829 |
|
| 830 |
*Effects:* Constructs an empty `forward_list` object using the specified
|
| 831 |
allocator.
|
| 832 |
|
| 833 |
*Complexity:* Constant.
|
| 834 |
|
| 835 |
``` cpp
|
| 836 |
+
explicit forward_list(size_type n, const Allocator& = Allocator());
|
| 837 |
```
|
| 838 |
|
| 839 |
+
*Effects:* Constructs a `forward_list` object with `n` default-inserted
|
| 840 |
+
elements using the specified allocator.
|
| 841 |
|
| 842 |
+
*Requires:* `T` shall be `DefaultInsertable` into `*this`.
|
| 843 |
|
| 844 |
*Complexity:* Linear in `n`.
|
| 845 |
|
| 846 |
``` cpp
|
| 847 |
forward_list(size_type n, const T& value, const Allocator& = Allocator());
|
|
|
|
| 862 |
*Effects:* Constructs a `forward_list` object equal to the range
|
| 863 |
\[`first`, `last`).
|
| 864 |
|
| 865 |
*Complexity:* Linear in `distance(first, last)`.
|
| 866 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 867 |
#### `forward_list` iterators <a id="forwardlist.iter">[[forwardlist.iter]]</a>
|
| 868 |
|
| 869 |
``` cpp
|
| 870 |
iterator before_begin() noexcept;
|
| 871 |
const_iterator before_begin() const noexcept;
|
|
|
|
| 964 |
```
|
| 965 |
|
| 966 |
*Effects:* `insert_after(p, il.begin(), il.end())`.
|
| 967 |
|
| 968 |
*Returns:* An iterator pointing to the last inserted element or
|
| 969 |
+
`position` if `il` is empty.
|
| 970 |
|
| 971 |
``` cpp
|
| 972 |
template <class... Args>
|
| 973 |
iterator emplace_after(const_iterator position, Args&&... args);
|
| 974 |
```
|
|
|
|
| 1008 |
|
| 1009 |
*Throws:* Nothing.
|
| 1010 |
|
| 1011 |
``` cpp
|
| 1012 |
void resize(size_type sz);
|
| 1013 |
+
```
|
| 1014 |
+
|
| 1015 |
+
*Effects:* If `sz < distance(begin(), end())`, erases the last
|
| 1016 |
+
`distance(begin(), end()) - sz` elements from the list. Otherwise,
|
| 1017 |
+
inserts `sz - distance(begin(), end())` default-inserted elements at the
|
| 1018 |
+
end of the list.
|
| 1019 |
+
|
| 1020 |
+
*Requires:* `T` shall be `DefaultInsertable` into `*this`.
|
| 1021 |
+
|
| 1022 |
+
``` cpp
|
| 1023 |
void resize(size_type sz, const value_type& c);
|
| 1024 |
```
|
| 1025 |
|
| 1026 |
*Effects:* If `sz < distance(begin(), end())`, erases the last
|
| 1027 |
`distance(begin(), end()) - sz` elements from the list. Otherwise,
|
| 1028 |
+
inserts `sz - distance(begin(), end())` elements at the end of the list
|
| 1029 |
+
such that each new element, `e`, is initialized by a method equivalent
|
| 1030 |
+
to calling
|
| 1031 |
+
`allocator_traits<allocator_type>::construct(get_allocator(), std::addressof(e), c)`.
|
| 1032 |
|
| 1033 |
+
*Requires:* `T` shall be `CopyInsertable` into `*this`.
|
|
|
|
| 1034 |
|
| 1035 |
``` cpp
|
| 1036 |
void clear() noexcept;
|
| 1037 |
```
|
| 1038 |
|
|
|
|
| 1046 |
void splice_after(const_iterator position, forward_list& x);
|
| 1047 |
void splice_after(const_iterator position, forward_list&& x);
|
| 1048 |
```
|
| 1049 |
|
| 1050 |
*Requires:* `position` is `before_begin()` or is a dereferenceable
|
| 1051 |
+
iterator in the range \[`begin()`, `end()`).
|
| 1052 |
+
`get_allocator() == x.get_allocator()`. `&x != this`.
|
| 1053 |
|
| 1054 |
*Effects:* Inserts the contents of `x` after `position`, and `x` becomes
|
| 1055 |
empty. Pointers and references to the moved elements of `x` now refer to
|
| 1056 |
those same elements but as members of `*this`. Iterators referring to
|
| 1057 |
the moved elements will continue to refer to their elements, but they
|
|
|
|
| 1067 |
```
|
| 1068 |
|
| 1069 |
*Requires:* `position` is `before_begin()` or is a dereferenceable
|
| 1070 |
iterator in the range \[`begin()`, `end()`). The iterator following `i`
|
| 1071 |
is a dereferenceable iterator in `x`.
|
| 1072 |
+
`get_allocator() == x.get_allocator()`.
|
| 1073 |
|
| 1074 |
*Effects:* Inserts the element following `i` into `*this`, following
|
| 1075 |
`position`, and removes it from `x`. The result is unchanged if
|
| 1076 |
+
`position == i` or `position == ++i`. Pointers and references to `*++i`
|
| 1077 |
continue to refer to the same element but as a member of `*this`.
|
| 1078 |
+
Iterators to `*++i` continue to refer to the same element, but now
|
| 1079 |
+
behave as iterators into `*this`, not into `x`.
|
| 1080 |
|
| 1081 |
*Throws:* Nothing.
|
| 1082 |
|
| 1083 |
*Complexity:* 𝑂(1)
|
| 1084 |
|
|
|
|
| 1091 |
|
| 1092 |
*Requires:* `position` is `before_begin()` or is a dereferenceable
|
| 1093 |
iterator in the range \[`begin()`, `end()`). (`first`, `last`) is a
|
| 1094 |
valid range in `x`, and all iterators in the range (`first`, `last`) are
|
| 1095 |
dereferenceable. `position` is not an iterator in the range (`first`,
|
| 1096 |
+
`last`). `get_allocator() == x.get_allocator()`.
|
| 1097 |
|
| 1098 |
*Effects:* Inserts elements in the range (`first`, `last`) after
|
| 1099 |
`position` and removes the elements from `x`. Pointers and references to
|
| 1100 |
the moved elements of `x` now refer to those same elements but as
|
| 1101 |
members of `*this`. Iterators referring to the moved elements will
|
|
|
|
| 1109 |
template <class Predicate> void remove_if(Predicate pred);
|
| 1110 |
```
|
| 1111 |
|
| 1112 |
*Effects:* Erases all the elements in the list referred by a list
|
| 1113 |
iterator `i` for which the following conditions hold: `*i == value` (for
|
| 1114 |
+
`remove()`), `pred(*i)` is true (for `remove_if()`). Invalidates only
|
| 1115 |
+
the iterators and references to the erased elements.
|
|
|
|
|
|
|
| 1116 |
|
| 1117 |
*Throws:* Nothing unless an exception is thrown by the equality
|
| 1118 |
comparison or the predicate.
|
| 1119 |
|
| 1120 |
+
*Remarks:* Stable ([[algorithm.stable]]).
|
| 1121 |
+
|
| 1122 |
*Complexity:* Exactly `distance(begin(), end())` applications of the
|
| 1123 |
corresponding predicate.
|
| 1124 |
|
| 1125 |
``` cpp
|
| 1126 |
void unique();
|
|
|
|
| 1142 |
otherwise no applications of the predicate.
|
| 1143 |
|
| 1144 |
``` cpp
|
| 1145 |
void merge(forward_list& x);
|
| 1146 |
void merge(forward_list&& x);
|
| 1147 |
+
template <class Compare> void merge(forward_list& x, Compare comp);
|
| 1148 |
+
template <class Compare> void merge(forward_list&& x, Compare comp);
|
| 1149 |
```
|
| 1150 |
|
| 1151 |
*Requires:* `comp` defines a strict weak ordering ([[alg.sorting]]),
|
| 1152 |
and `*this` and `x` are both sorted according to this ordering.
|
| 1153 |
+
`get_allocator() == x.get_allocator()`.
|
| 1154 |
|
| 1155 |
+
*Effects:* Merges the two sorted ranges `[begin(), end())` and
|
| 1156 |
+
`[x.begin(), x.end())`. `x` is empty after the merge. If an exception is
|
| 1157 |
+
thrown other than by a comparison there are no effects. Pointers and
|
| 1158 |
+
references to the moved elements of `x` now refer to those same elements
|
| 1159 |
+
but as members of `*this`. Iterators referring to the moved elements
|
| 1160 |
+
will continue to refer to their elements, but they now behave as
|
| 1161 |
+
iterators into `*this`, not into `x`.
|
|
|
|
| 1162 |
|
| 1163 |
+
*Remarks:* Stable ([[algorithm.stable]]). The behavior is undefined if
|
| 1164 |
+
`this->get_allocator() != x.get_allocator()`.
|
| 1165 |
+
|
| 1166 |
+
*Complexity:* At most
|
| 1167 |
+
`distance(begin(), end()) + distance(x.begin(), x.end()) - 1`
|
| 1168 |
+
comparisons.
|
| 1169 |
|
| 1170 |
``` cpp
|
| 1171 |
void sort();
|
| 1172 |
template <class Compare> void sort(Compare comp);
|
| 1173 |
```
|
|
|
|
| 1175 |
*Requires:* `operator<` (for the version with no arguments) or `comp`
|
| 1176 |
(for the version with a comparison argument) defines a strict weak
|
| 1177 |
ordering ([[alg.sorting]]).
|
| 1178 |
|
| 1179 |
*Effects:* Sorts the list according to the `operator<` or the `comp`
|
| 1180 |
+
function object. If an exception is thrown the order of the elements in
|
| 1181 |
+
`*this` is unspecified. Does not affect the validity of iterators and
|
| 1182 |
+
references.
|
| 1183 |
+
|
| 1184 |
+
*Remarks:* Stable ([[algorithm.stable]]).
|
| 1185 |
|
| 1186 |
*Complexity:* Approximately N log N comparisons, where N is
|
| 1187 |
`distance(begin(), end())`.
|
| 1188 |
|
| 1189 |
``` cpp
|
|
|
|
| 1244 |
typedef typename allocator_traits<Allocator>::const_pointer const_pointer;
|
| 1245 |
typedef std::reverse_iterator<iterator> reverse_iterator;
|
| 1246 |
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
| 1247 |
|
| 1248 |
// [list.cons], construct/copy/destroy:
|
| 1249 |
+
list() : list(Allocator()) { }
|
| 1250 |
+
explicit list(const Allocator&);
|
| 1251 |
+
explicit list(size_type n, const Allocator& = Allocator());
|
| 1252 |
list(size_type n, const T& value, const Allocator& = Allocator());
|
| 1253 |
template <class InputIterator>
|
| 1254 |
list(InputIterator first, InputIterator last, const Allocator& = Allocator());
|
| 1255 |
list(const list& x);
|
| 1256 |
list(list&& x);
|
|
|
|
| 1367 |
```
|
| 1368 |
|
| 1369 |
#### `list` constructors, copy, and assignment <a id="list.cons">[[list.cons]]</a>
|
| 1370 |
|
| 1371 |
``` cpp
|
| 1372 |
+
explicit list(const Allocator&);
|
| 1373 |
```
|
| 1374 |
|
| 1375 |
*Effects:* Constructs an empty list, using the specified allocator.
|
| 1376 |
|
| 1377 |
*Complexity:* Constant.
|
| 1378 |
|
| 1379 |
``` cpp
|
| 1380 |
+
explicit list(size_type n, const Allocator& = Allocator());
|
| 1381 |
```
|
| 1382 |
|
| 1383 |
+
*Effects:* Constructs a `list` with `n` default-inserted elements using
|
| 1384 |
+
the specified allocator.
|
| 1385 |
|
| 1386 |
+
*Requires:* `T` shall be `DefaultInsertable` into `*this`.
|
| 1387 |
|
| 1388 |
*Complexity:* Linear in `n`.
|
| 1389 |
|
| 1390 |
``` cpp
|
| 1391 |
list(size_type n, const T& value,
|
|
|
|
| 1407 |
|
| 1408 |
*Effects:* Constructs a `list` equal to the range \[`first`, `last`).
|
| 1409 |
|
| 1410 |
*Complexity:* Linear in `distance(first, last)`.
|
| 1411 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1412 |
#### `list` capacity <a id="list.capacity">[[list.capacity]]</a>
|
| 1413 |
|
| 1414 |
``` cpp
|
| 1415 |
void resize(size_type sz);
|
| 1416 |
```
|
| 1417 |
|
| 1418 |
+
*Effects:* If `size() < sz`, appends `sz - size()` default-inserted
|
| 1419 |
elements to the sequence. If `sz <= size()`, equivalent to
|
| 1420 |
|
| 1421 |
``` cpp
|
| 1422 |
list<T>::iterator it = begin();
|
| 1423 |
advance(it, sz);
|
| 1424 |
erase(it, end());
|
| 1425 |
```
|
| 1426 |
|
| 1427 |
+
*Requires:* `T` shall be `DefaultInsertable` into `*this`.
|
| 1428 |
|
| 1429 |
``` cpp
|
| 1430 |
void resize(size_type sz, const T& c);
|
| 1431 |
```
|
| 1432 |
|
|
|
|
| 1571 |
references to the erased elements.
|
| 1572 |
|
| 1573 |
*Throws:* Nothing unless an exception is thrown by `*i == value` or
|
| 1574 |
`pred(*i) != false`.
|
| 1575 |
|
| 1576 |
+
*Remarks:* Stable ([[algorithm.stable]]).
|
| 1577 |
|
| 1578 |
*Complexity:* Exactly `size()` applications of the corresponding
|
| 1579 |
predicate.
|
| 1580 |
|
| 1581 |
``` cpp
|
|
|
|
| 1588 |
\[`first + 1`, `last`) for which `*i == *(i-1)` (for the version of
|
| 1589 |
`unique` with no arguments) or `pred(*i, *(i - 1))` (for the version of
|
| 1590 |
`unique` with a predicate argument) holds. Invalidates only the
|
| 1591 |
iterators and references to the erased elements.
|
| 1592 |
|
| 1593 |
+
*Throws:* Nothing unless an exception is thrown by `*i == *(i-1)` or
|
| 1594 |
`pred(*i, *(i - 1))`
|
| 1595 |
|
| 1596 |
*Complexity:* If the range `[first, last)` is not empty, exactly
|
| 1597 |
`(last - first) - 1` applications of the corresponding predicate,
|
| 1598 |
otherwise no applications of the predicate.
|
|
|
|
| 1617 |
elements of `x` now refer to those same elements but as members of
|
| 1618 |
`*this`. Iterators referring to the moved elements will continue to
|
| 1619 |
refer to their elements, but they now behave as iterators into `*this`,
|
| 1620 |
not into `x`.
|
| 1621 |
|
| 1622 |
+
*Remarks:* Stable ([[algorithm.stable]]). If `(&x != this)` the range
|
| 1623 |
+
`[x.begin(), x.end())` is empty after the merge. No elements are copied
|
| 1624 |
+
by this operation. The behavior is undefined if
|
| 1625 |
+
`this->get_allocator() != x.get_allocator()`.
|
| 1626 |
|
| 1627 |
*Complexity:* At most `size() + x.size() - 1` applications of `comp` if
|
| 1628 |
`(&x != this)`; otherwise, no applications of `comp` are performed. If
|
| 1629 |
an exception is thrown other than by a comparison there are no effects.
|
| 1630 |
|
|
|
|
| 1647 |
|
| 1648 |
*Effects:* Sorts the list according to the `operator<` or a `Compare`
|
| 1649 |
function object. Does not affect the validity of iterators and
|
| 1650 |
references.
|
| 1651 |
|
| 1652 |
+
*Remarks:* Stable ([[algorithm.stable]]).
|
| 1653 |
|
| 1654 |
*Complexity:* Approximately N log(N) comparisons, where `N == size()`.
|
| 1655 |
|
| 1656 |
#### `list` specialized algorithms <a id="list.special">[[list.special]]</a>
|
| 1657 |
|
|
|
|
| 1708 |
typedef typename allocator_traits<Allocator>::const_pointer const_pointer;
|
| 1709 |
typedef std::reverse_iterator<iterator> reverse_iterator;
|
| 1710 |
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
| 1711 |
|
| 1712 |
// [vector.cons], construct/copy/destroy:
|
| 1713 |
+
vector() : vector(Allocator()) { }
|
| 1714 |
+
explicit vector(const Allocator&);
|
| 1715 |
+
explicit vector(size_type n, const Allocator& = Allocator());
|
| 1716 |
vector(size_type n, const T& value, const Allocator& = Allocator());
|
| 1717 |
template <class InputIterator>
|
| 1718 |
vector(InputIterator first, InputIterator last,
|
| 1719 |
const Allocator& = Allocator());
|
| 1720 |
vector(const vector& x);
|
|
|
|
| 1811 |
```
|
| 1812 |
|
| 1813 |
#### `vector` constructors, copy, and assignment <a id="vector.cons">[[vector.cons]]</a>
|
| 1814 |
|
| 1815 |
``` cpp
|
| 1816 |
+
explicit vector(const Allocator&);
|
| 1817 |
```
|
| 1818 |
|
| 1819 |
*Effects:* Constructs an empty `vector`, using the specified allocator.
|
| 1820 |
|
| 1821 |
*Complexity:* Constant.
|
| 1822 |
|
| 1823 |
``` cpp
|
| 1824 |
+
explicit vector(size_type n, const Allocator& = Allocator());
|
| 1825 |
```
|
| 1826 |
|
| 1827 |
+
*Effects:* Constructs a `vector` with `n` default-inserted elements
|
| 1828 |
+
using the specified allocator.
|
| 1829 |
|
| 1830 |
+
*Requires:* `T` shall be `DefaultInsertable` into `*this`.
|
| 1831 |
|
| 1832 |
*Complexity:* Linear in `n`.
|
| 1833 |
|
| 1834 |
``` cpp
|
| 1835 |
vector(size_type n, const T& value,
|
|
|
|
| 1856 |
is the distance between `first` and `last`) and no reallocations if
|
| 1857 |
iterators first and last are of forward, bidirectional, or random access
|
| 1858 |
categories. It makes order `N` calls to the copy constructor of `T` and
|
| 1859 |
order log(N) reallocations if they are just input iterators.
|
| 1860 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1861 |
#### `vector` capacity <a id="vector.capacity">[[vector.capacity]]</a>
|
| 1862 |
|
| 1863 |
``` cpp
|
| 1864 |
size_type capacity() const noexcept;
|
| 1865 |
```
|
|
|
|
| 1869 |
|
| 1870 |
``` cpp
|
| 1871 |
void reserve(size_type n);
|
| 1872 |
```
|
| 1873 |
|
| 1874 |
+
*Requires:* `T` shall be `MoveInsertable` into `*this`.
|
| 1875 |
+
|
| 1876 |
*Effects:* A directive that informs a `vector` of a planned change in
|
| 1877 |
size, so that it can manage the storage allocation accordingly. After
|
| 1878 |
`reserve()`, `capacity()` is greater or equal to the argument of
|
| 1879 |
`reserve` if reallocation happens; and equal to the previous value of
|
| 1880 |
`capacity()` otherwise. Reallocation happens at this point if and only
|
|
|
|
| 1886 |
most linear time in the size of the sequence.
|
| 1887 |
|
| 1888 |
*Throws:* `length_error` if `n > max_size()`.[^4]
|
| 1889 |
|
| 1890 |
*Remarks:* Reallocation invalidates all the references, pointers, and
|
| 1891 |
+
iterators referring to the elements in the sequence. No reallocation
|
| 1892 |
+
shall take place during insertions that happen after a call to
|
| 1893 |
+
`reserve()` until the time when an insertion would make the size of the
|
| 1894 |
+
vector greater than the value of `capacity()`.
|
| 1895 |
|
| 1896 |
``` cpp
|
| 1897 |
void shrink_to_fit();
|
| 1898 |
```
|
| 1899 |
|
| 1900 |
+
*Requires:* `T` shall be `MoveInsertable` into `*this`.
|
| 1901 |
+
|
| 1902 |
+
*Complexity:* Linear in the size of the sequence.
|
| 1903 |
+
|
| 1904 |
*Remarks:* `shrink_to_fit` is a non-binding request to reduce
|
| 1905 |
`capacity()` to `size()`. The request is non-binding to allow latitude
|
| 1906 |
+
for implementation-specific optimizations. If an exception is thrown
|
| 1907 |
+
other than by the move constructor of a non-`CopyInsertable` `T` there
|
| 1908 |
+
are no effects.
|
| 1909 |
|
| 1910 |
``` cpp
|
| 1911 |
void swap(vector& x);
|
| 1912 |
```
|
| 1913 |
|
|
|
|
| 1918 |
|
| 1919 |
``` cpp
|
| 1920 |
void resize(size_type sz);
|
| 1921 |
```
|
| 1922 |
|
| 1923 |
+
*Effects:* If `sz <= size()`, equivalent to calling `pop_back()`
|
| 1924 |
+
`size() - sz` times. If `size() < sz`, appends `sz - size()`
|
| 1925 |
+
default-inserted elements to the sequence.
|
| 1926 |
|
| 1927 |
+
*Requires:* `T` shall be `MoveInsertable` and `DefaultInsertable` into
|
| 1928 |
+
`*this`.
|
| 1929 |
|
| 1930 |
+
*Remarks:* If an exception is thrown other than by the move constructor
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1931 |
of a non-`CopyInsertable` `T` there are no effects.
|
| 1932 |
|
| 1933 |
+
``` cpp
|
| 1934 |
+
void resize(size_type sz, const T& c);
|
| 1935 |
+
```
|
| 1936 |
+
|
| 1937 |
+
*Effects:* If `sz <= size()`, equivalent to calling `pop_back()`
|
| 1938 |
+
`size() - sz` times. If `size() < sz`, appends `sz - size()` copies of
|
| 1939 |
+
`c` to the sequence.
|
| 1940 |
+
|
| 1941 |
+
*Requires:* `T` shall be `CopyInsertable` into `*this`.
|
| 1942 |
+
|
| 1943 |
+
*Remarks:* If an exception is thrown there are no effects.
|
| 1944 |
+
|
| 1945 |
#### `vector` data <a id="vector.data">[[vector.data]]</a>
|
| 1946 |
|
| 1947 |
``` cpp
|
| 1948 |
T* data() noexcept;
|
| 1949 |
const T* data() const noexcept;
|
|
|
|
| 1973 |
*Remarks:* Causes reallocation if the new size is greater than the old
|
| 1974 |
capacity. If no reallocation happens, all the iterators and references
|
| 1975 |
before the insertion point remain valid. If an exception is thrown other
|
| 1976 |
than by the copy constructor, move constructor, assignment operator, or
|
| 1977 |
move assignment operator of `T` or by any `InputIterator` operation
|
| 1978 |
+
there are no effects. If an exception is thrown while inserting a single
|
| 1979 |
+
element at the end and `T` is `CopyInsertable` or
|
| 1980 |
+
`is_nothrow_move_constructible<T>::value` is `true`, there are no
|
| 1981 |
+
effects. Otherwise, if an exception is thrown by the move constructor of
|
| 1982 |
+
a non-`CopyInsertable` `T`, the effects are unspecified.
|
| 1983 |
|
| 1984 |
*Complexity:* The complexity is linear in the number of elements
|
| 1985 |
inserted plus the distance to the end of the vector.
|
| 1986 |
|
| 1987 |
``` cpp
|
|
|
|
| 2047 |
reference& operator=(const reference& x) noexcept;
|
| 2048 |
void flip() noexcept; // flips the bit
|
| 2049 |
};
|
| 2050 |
|
| 2051 |
// construct/copy/destroy:
|
| 2052 |
+
vector() : vector(Allocator()) { }
|
| 2053 |
+
explicit vector(const Allocator&);
|
| 2054 |
+
explicit vector(size_type n, const Allocator& = Allocator());
|
| 2055 |
+
vector(size_type n, const bool& value,
|
| 2056 |
const Allocator& = Allocator());
|
| 2057 |
template <class InputIterator>
|
| 2058 |
vector(InputIterator first, InputIterator last,
|
| 2059 |
const Allocator& = Allocator());
|
| 2060 |
vector(const vector<bool,Allocator>& x);
|
|
|
|
| 2063 |
vector(vector&&, const Allocator&);
|
| 2064 |
vector(initializer_list<bool>, const Allocator& = Allocator()));
|
| 2065 |
~vector();
|
| 2066 |
vector<bool,Allocator>& operator=(const vector<bool,Allocator>& x);
|
| 2067 |
vector<bool,Allocator>& operator=(vector<bool,Allocator>&& x);
|
| 2068 |
+
vector& operator=(initializer_list<bool>);
|
| 2069 |
template <class InputIterator>
|
| 2070 |
void assign(InputIterator first, InputIterator last);
|
| 2071 |
void assign(size_type n, const bool& t);
|
| 2072 |
+
void assign(initializer_list<bool>);
|
| 2073 |
allocator_type get_allocator() const noexcept;
|
| 2074 |
|
| 2075 |
// iterators:
|
| 2076 |
iterator begin() noexcept;
|
| 2077 |
const_iterator begin() const noexcept;
|
|
|
|
| 2105 |
const_reference front() const;
|
| 2106 |
reference back();
|
| 2107 |
const_reference back() const;
|
| 2108 |
|
| 2109 |
// modifiers:
|
| 2110 |
+
template <class... Args> void emplace_back(Args&&... args);
|
| 2111 |
void push_back(const bool& x);
|
| 2112 |
void pop_back();
|
| 2113 |
+
template <class... Args> iterator emplace(const_iterator position, Args&&... args);
|
| 2114 |
iterator insert(const_iterator position, const bool& x);
|
| 2115 |
iterator insert (const_iterator position, size_type n, const bool& x);
|
| 2116 |
template <class InputIterator>
|
| 2117 |
iterator insert(const_iterator position,
|
| 2118 |
InputIterator first, InputIterator last);
|
|
|
|
| 2166 |
|
| 2167 |
``` cpp
|
| 2168 |
template <class Allocator> struct hash<vector<bool, Allocator> >;
|
| 2169 |
```
|
| 2170 |
|
| 2171 |
+
The template specialization shall meet the requirements of class
|
| 2172 |
+
template `hash` ([[unord.hash]]).
|
| 2173 |
|