tmp/tmppignvwo4/{from.md → to.md}
RENAMED
|
@@ -24,24 +24,24 @@ information.
|
|
| 24 |
namespace std {
|
| 25 |
template <class T, class Allocator = allocator<T>>
|
| 26 |
class list {
|
| 27 |
public:
|
| 28 |
// types:
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 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>
|
|
@@ -51,11 +51,12 @@ namespace std {
|
|
| 51 |
list(const list&, const Allocator&);
|
| 52 |
list(list&&, const Allocator&);
|
| 53 |
list(initializer_list<T>, const Allocator& = Allocator());
|
| 54 |
~list();
|
| 55 |
list& operator=(const list& x);
|
| 56 |
-
list& operator=(list&& x)
|
|
|
|
| 57 |
list& operator=(initializer_list<T>);
|
| 58 |
template <class InputIterator>
|
| 59 |
void assign(InputIterator first, InputIterator last);
|
| 60 |
void assign(size_type n, const T& t);
|
| 61 |
void assign(initializer_list<T>);
|
|
@@ -74,11 +75,11 @@ namespace std {
|
|
| 74 |
const_iterator cbegin() const noexcept;
|
| 75 |
const_iterator cend() const noexcept;
|
| 76 |
const_reverse_iterator crbegin() const noexcept;
|
| 77 |
const_reverse_iterator crend() const noexcept;
|
| 78 |
|
| 79 |
-
// [list.capacity], capacity
|
| 80 |
bool empty() const noexcept;
|
| 81 |
size_type size() const noexcept;
|
| 82 |
size_type max_size() const noexcept;
|
| 83 |
void resize(size_type sz);
|
| 84 |
void resize(size_type sz, const T& c);
|
|
@@ -87,16 +88,16 @@ namespace std {
|
|
| 87 |
reference front();
|
| 88 |
const_reference front() const;
|
| 89 |
reference back();
|
| 90 |
const_reference back() const;
|
| 91 |
|
| 92 |
-
// [list.modifiers], modifiers
|
| 93 |
-
template <class... Args>
|
| 94 |
-
|
| 95 |
-
template <class... Args> void emplace_back(Args&&... args);
|
| 96 |
void push_front(const T& x);
|
| 97 |
void push_front(T&& x);
|
|
|
|
| 98 |
void push_back(const T& x);
|
| 99 |
void push_back(T&& x);
|
| 100 |
void pop_back();
|
| 101 |
|
| 102 |
template <class... Args> iterator emplace(const_iterator position, Args&&... args);
|
|
@@ -108,14 +109,15 @@ namespace std {
|
|
| 108 |
InputIterator last);
|
| 109 |
iterator insert(const_iterator position, initializer_list<T> il);
|
| 110 |
|
| 111 |
iterator erase(const_iterator position);
|
| 112 |
iterator erase(const_iterator position, const_iterator last);
|
| 113 |
-
void swap(list&)
|
|
|
|
| 114 |
void clear() noexcept;
|
| 115 |
|
| 116 |
-
// [list.ops], list operations
|
| 117 |
void splice(const_iterator position, list& x);
|
| 118 |
void splice(const_iterator position, list&& x);
|
| 119 |
void splice(const_iterator position, list& x, const_iterator i);
|
| 120 |
void splice(const_iterator position, list&& x, const_iterator i);
|
| 121 |
void splice(const_iterator position, list& x,
|
|
@@ -139,10 +141,15 @@ namespace std {
|
|
| 139 |
template <class Compare> void sort(Compare comp);
|
| 140 |
|
| 141 |
void reverse() noexcept;
|
| 142 |
};
|
| 143 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 144 |
template <class T, class Allocator>
|
| 145 |
bool operator==(const list<T, Allocator>& x, const list<T, Allocator>& y);
|
| 146 |
template <class T, class Allocator>
|
| 147 |
bool operator< (const list<T, Allocator>& x, const list<T, Allocator>& y);
|
| 148 |
template <class T, class Allocator>
|
|
@@ -152,16 +159,22 @@ namespace std {
|
|
| 152 |
template <class T, class Allocator>
|
| 153 |
bool operator>=(const list<T, Allocator>& x, const list<T, Allocator>& y);
|
| 154 |
template <class T, class Allocator>
|
| 155 |
bool operator<=(const list<T, Allocator>& x, const list<T, Allocator>& y);
|
| 156 |
|
| 157 |
-
// specialized algorithms
|
| 158 |
template <class T, class Allocator>
|
| 159 |
-
void swap(list<T,Allocator>& x, list<T,Allocator>& y)
|
|
|
|
| 160 |
}
|
| 161 |
```
|
| 162 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 163 |
#### `list` constructors, copy, and assignment <a id="list.cons">[[list.cons]]</a>
|
| 164 |
|
| 165 |
``` cpp
|
| 166 |
explicit list(const Allocator&);
|
| 167 |
```
|
|
@@ -180,12 +193,11 @@ the specified allocator.
|
|
| 180 |
*Requires:* `T` shall be `DefaultInsertable` into `*this`.
|
| 181 |
|
| 182 |
*Complexity:* Linear in `n`.
|
| 183 |
|
| 184 |
``` cpp
|
| 185 |
-
list(size_type n, const T& value,
|
| 186 |
-
const Allocator& = Allocator());
|
| 187 |
```
|
| 188 |
|
| 189 |
*Effects:* Constructs a `list` with `n` copies of `value`, using the
|
| 190 |
specified allocator.
|
| 191 |
|
|
@@ -193,12 +205,11 @@ specified allocator.
|
|
| 193 |
|
| 194 |
*Complexity:* Linear in `n`.
|
| 195 |
|
| 196 |
``` cpp
|
| 197 |
template <class InputIterator>
|
| 198 |
-
list(InputIterator first, InputIterator last,
|
| 199 |
-
const Allocator& = Allocator());
|
| 200 |
```
|
| 201 |
|
| 202 |
*Effects:* Constructs a `list` equal to the range \[`first`, `last`).
|
| 203 |
|
| 204 |
*Complexity:* Linear in `distance(first, last)`.
|
|
@@ -208,11 +219,11 @@ list(InputIterator first, InputIterator last,
|
|
| 208 |
``` cpp
|
| 209 |
void resize(size_type sz);
|
| 210 |
```
|
| 211 |
|
| 212 |
*Effects:* If `size() < sz`, appends `sz - size()` default-inserted
|
| 213 |
-
elements to the sequence. If `sz <= size()`, equivalent to
|
| 214 |
|
| 215 |
``` cpp
|
| 216 |
list<T>::iterator it = begin();
|
| 217 |
advance(it, sz);
|
| 218 |
erase(it, end());
|
|
@@ -222,11 +233,11 @@ erase(it, end());
|
|
| 222 |
|
| 223 |
``` cpp
|
| 224 |
void resize(size_type sz, const T& c);
|
| 225 |
```
|
| 226 |
|
| 227 |
-
*Effects:*
|
| 228 |
|
| 229 |
``` cpp
|
| 230 |
if (sz > size())
|
| 231 |
insert(end(), sz-size(), c);
|
| 232 |
else if (sz < size()) {
|
|
@@ -249,12 +260,12 @@ iterator insert(const_iterator position, size_type n, const T& x);
|
|
| 249 |
template <class InputIterator>
|
| 250 |
iterator insert(const_iterator position, InputIterator first,
|
| 251 |
InputIterator last);
|
| 252 |
iterator insert(const_iterator position, initializer_list<T>);
|
| 253 |
|
| 254 |
-
template <class... Args>
|
| 255 |
-
template <class... Args>
|
| 256 |
template <class... Args> iterator emplace(const_iterator position, Args&&... args);
|
| 257 |
void push_front(const T& x);
|
| 258 |
void push_front(T&& x);
|
| 259 |
void push_back(const T& x);
|
| 260 |
void push_back(T&& x);
|
|
@@ -318,19 +329,19 @@ now behave as iterators into `*this`, not into `x`.
|
|
| 318 |
``` cpp
|
| 319 |
void splice(const_iterator position, list& x, const_iterator i);
|
| 320 |
void splice(const_iterator position, list&& x, const_iterator i);
|
| 321 |
```
|
| 322 |
|
|
|
|
|
|
|
| 323 |
*Effects:* Inserts an element pointed to by `i` from list `x` before
|
| 324 |
`position` and removes the element from `x`. The result is unchanged if
|
| 325 |
`position == i` or `position == ++i`. Pointers and references to `*i`
|
| 326 |
continue to refer to this same element but as a member of `*this`.
|
| 327 |
Iterators to `*i` (including `i` itself) continue to refer to the same
|
| 328 |
element, but now behave as iterators into `*this`, not into `x`.
|
| 329 |
|
| 330 |
-
*Requires:* `i` is a valid dereferenceable iterator of `x`.
|
| 331 |
-
|
| 332 |
*Throws:* Nothing.
|
| 333 |
|
| 334 |
*Complexity:* Constant time.
|
| 335 |
|
| 336 |
``` cpp
|
|
@@ -338,19 +349,20 @@ void splice(const_iterator position, list& x, const_iterator first,
|
|
| 338 |
const_iterator last);
|
| 339 |
void splice(const_iterator position, list&& x, const_iterator first,
|
| 340 |
const_iterator last);
|
| 341 |
```
|
| 342 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 343 |
*Effects:* Inserts elements in the range \[`first`, `last`) before
|
| 344 |
-
`position` and removes the elements from `x`.
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
same elements but as members of `*this`. Iterators referring to the
|
| 350 |
-
moved elements will continue to refer to their elements, but they now
|
| 351 |
-
behave as iterators into `*this`, not into `x`.
|
| 352 |
|
| 353 |
*Throws:* Nothing.
|
| 354 |
|
| 355 |
*Complexity:* Constant time if `&x == this`; otherwise, linear time.
|
| 356 |
|
|
@@ -405,20 +417,20 @@ shall be sorted according to this ordering.
|
|
| 405 |
*Effects:* If `(&x == this)` does nothing; otherwise, merges the two
|
| 406 |
sorted ranges `[begin(), end())` and `[x.begin(), x.end())`. The result
|
| 407 |
is a range in which the elements will be sorted in non-decreasing order
|
| 408 |
according to the ordering defined by `comp`; that is, for every iterator
|
| 409 |
`i`, in the range other than the first, the condition
|
| 410 |
-
`comp(*i, *(i - 1))` will be false. Pointers and references to the
|
| 411 |
-
elements of `x` now refer to those same elements but as members of
|
| 412 |
`*this`. Iterators referring to the moved elements will continue to
|
| 413 |
refer to their elements, but they now behave as iterators into `*this`,
|
| 414 |
not into `x`.
|
| 415 |
|
| 416 |
*Remarks:* Stable ([[algorithm.stable]]). If `(&x != this)` the range
|
| 417 |
`[x.begin(), x.end())` is empty after the merge. No elements are copied
|
| 418 |
by this operation. The behavior is undefined if
|
| 419 |
-
`
|
| 420 |
|
| 421 |
*Complexity:* At most `size() + x.size() - 1` applications of `comp` if
|
| 422 |
`(&x != this)`; otherwise, no applications of `comp` are performed. If
|
| 423 |
an exception is thrown other than by a comparison there are no effects.
|
| 424 |
|
|
@@ -438,25 +450,23 @@ template <class Compare> void sort(Compare comp);
|
|
| 438 |
|
| 439 |
*Requires:* `operator<` (for the first version) or `comp` (for the
|
| 440 |
second version) shall define a strict weak ordering ([[alg.sorting]]).
|
| 441 |
|
| 442 |
*Effects:* Sorts the list according to the `operator<` or a `Compare`
|
| 443 |
-
function object.
|
|
|
|
| 444 |
references.
|
| 445 |
|
| 446 |
*Remarks:* Stable ([[algorithm.stable]]).
|
| 447 |
|
| 448 |
-
*Complexity:* Approximately N log
|
| 449 |
|
| 450 |
#### `list` specialized algorithms <a id="list.special">[[list.special]]</a>
|
| 451 |
|
| 452 |
``` cpp
|
| 453 |
template <class T, class Allocator>
|
| 454 |
-
void swap(list<T,Allocator>& x, list<T,Allocator>& y)
|
|
|
|
| 455 |
```
|
| 456 |
|
| 457 |
-
*Effects:*
|
| 458 |
-
|
| 459 |
-
``` cpp
|
| 460 |
-
x.swap(y);
|
| 461 |
-
```
|
| 462 |
|
|
|
|
| 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 = typename allocator_traits<Allocator>::pointer;
|
| 32 |
+
using const_pointer = typename allocator_traits<Allocator>::const_pointer;
|
| 33 |
+
using reference = value_type&;
|
| 34 |
+
using const_reference = const value_type&;
|
| 35 |
+
using size_type = implementation-defined; // see [container.requirements]
|
| 36 |
+
using difference_type = implementation-defined; // 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>
|
|
|
|
| 51 |
list(const list&, const Allocator&);
|
| 52 |
list(list&&, const Allocator&);
|
| 53 |
list(initializer_list<T>, const Allocator& = Allocator());
|
| 54 |
~list();
|
| 55 |
list& operator=(const list& x);
|
| 56 |
+
list& operator=(list&& x)
|
| 57 |
+
noexcept(allocator_traits<Allocator>::is_always_equal::value);
|
| 58 |
list& operator=(initializer_list<T>);
|
| 59 |
template <class InputIterator>
|
| 60 |
void assign(InputIterator first, InputIterator last);
|
| 61 |
void assign(size_type n, const T& t);
|
| 62 |
void assign(initializer_list<T>);
|
|
|
|
| 75 |
const_iterator cbegin() const noexcept;
|
| 76 |
const_iterator cend() const noexcept;
|
| 77 |
const_reverse_iterator crbegin() const noexcept;
|
| 78 |
const_reverse_iterator crend() const noexcept;
|
| 79 |
|
| 80 |
+
// [list.capacity], capacity
|
| 81 |
bool empty() const noexcept;
|
| 82 |
size_type size() const noexcept;
|
| 83 |
size_type max_size() const noexcept;
|
| 84 |
void resize(size_type sz);
|
| 85 |
void resize(size_type sz, const T& c);
|
|
|
|
| 88 |
reference front();
|
| 89 |
const_reference front() const;
|
| 90 |
reference back();
|
| 91 |
const_reference back() const;
|
| 92 |
|
| 93 |
+
// [list.modifiers], modifiers
|
| 94 |
+
template <class... Args> reference emplace_front(Args&&... args);
|
| 95 |
+
template <class... Args> reference emplace_back(Args&&... args);
|
|
|
|
| 96 |
void push_front(const T& x);
|
| 97 |
void push_front(T&& x);
|
| 98 |
+
void pop_front();
|
| 99 |
void push_back(const T& x);
|
| 100 |
void push_back(T&& x);
|
| 101 |
void pop_back();
|
| 102 |
|
| 103 |
template <class... Args> iterator emplace(const_iterator position, Args&&... args);
|
|
|
|
| 109 |
InputIterator last);
|
| 110 |
iterator insert(const_iterator position, initializer_list<T> il);
|
| 111 |
|
| 112 |
iterator erase(const_iterator position);
|
| 113 |
iterator erase(const_iterator position, const_iterator last);
|
| 114 |
+
void swap(list&)
|
| 115 |
+
noexcept(allocator_traits<Allocator>::is_always_equal::value);
|
| 116 |
void clear() noexcept;
|
| 117 |
|
| 118 |
+
// [list.ops], list operations
|
| 119 |
void splice(const_iterator position, list& x);
|
| 120 |
void splice(const_iterator position, list&& x);
|
| 121 |
void splice(const_iterator position, list& x, const_iterator i);
|
| 122 |
void splice(const_iterator position, list&& x, const_iterator i);
|
| 123 |
void splice(const_iterator position, list& x,
|
|
|
|
| 141 |
template <class Compare> void sort(Compare comp);
|
| 142 |
|
| 143 |
void reverse() noexcept;
|
| 144 |
};
|
| 145 |
|
| 146 |
+
template<class InputIterator,
|
| 147 |
+
class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>>
|
| 148 |
+
list(InputIterator, InputIterator, Allocator = Allocator())
|
| 149 |
+
-> list<typename iterator_traits<InputIterator>::value_type, Allocator>;
|
| 150 |
+
|
| 151 |
template <class T, class Allocator>
|
| 152 |
bool operator==(const list<T, Allocator>& x, const list<T, Allocator>& y);
|
| 153 |
template <class T, class Allocator>
|
| 154 |
bool operator< (const list<T, Allocator>& x, const list<T, Allocator>& y);
|
| 155 |
template <class T, class Allocator>
|
|
|
|
| 159 |
template <class T, class Allocator>
|
| 160 |
bool operator>=(const list<T, Allocator>& x, const list<T, Allocator>& y);
|
| 161 |
template <class T, class Allocator>
|
| 162 |
bool operator<=(const list<T, Allocator>& x, const list<T, Allocator>& y);
|
| 163 |
|
| 164 |
+
// [list.special], specialized algorithms
|
| 165 |
template <class T, class Allocator>
|
| 166 |
+
void swap(list<T, Allocator>& x, list<T, Allocator>& y)
|
| 167 |
+
noexcept(noexcept(x.swap(y)));
|
| 168 |
}
|
| 169 |
```
|
| 170 |
|
| 171 |
+
An incomplete type `T` may be used when instantiating `list` if the
|
| 172 |
+
allocator satisfies the allocator completeness requirements (
|
| 173 |
+
[[allocator.requirements.completeness]]). `T` shall be complete before
|
| 174 |
+
any member of the resulting specialization of `list` is referenced.
|
| 175 |
+
|
| 176 |
#### `list` constructors, copy, and assignment <a id="list.cons">[[list.cons]]</a>
|
| 177 |
|
| 178 |
``` cpp
|
| 179 |
explicit list(const Allocator&);
|
| 180 |
```
|
|
|
|
| 193 |
*Requires:* `T` shall be `DefaultInsertable` into `*this`.
|
| 194 |
|
| 195 |
*Complexity:* Linear in `n`.
|
| 196 |
|
| 197 |
``` cpp
|
| 198 |
+
list(size_type n, const T& value, const Allocator& = Allocator());
|
|
|
|
| 199 |
```
|
| 200 |
|
| 201 |
*Effects:* Constructs a `list` with `n` copies of `value`, using the
|
| 202 |
specified allocator.
|
| 203 |
|
|
|
|
| 205 |
|
| 206 |
*Complexity:* Linear in `n`.
|
| 207 |
|
| 208 |
``` cpp
|
| 209 |
template <class InputIterator>
|
| 210 |
+
list(InputIterator first, InputIterator last, const Allocator& = Allocator());
|
|
|
|
| 211 |
```
|
| 212 |
|
| 213 |
*Effects:* Constructs a `list` equal to the range \[`first`, `last`).
|
| 214 |
|
| 215 |
*Complexity:* Linear in `distance(first, last)`.
|
|
|
|
| 219 |
``` cpp
|
| 220 |
void resize(size_type sz);
|
| 221 |
```
|
| 222 |
|
| 223 |
*Effects:* If `size() < sz`, appends `sz - size()` default-inserted
|
| 224 |
+
elements to the sequence. If `sz <= size()`, equivalent to:
|
| 225 |
|
| 226 |
``` cpp
|
| 227 |
list<T>::iterator it = begin();
|
| 228 |
advance(it, sz);
|
| 229 |
erase(it, end());
|
|
|
|
| 233 |
|
| 234 |
``` cpp
|
| 235 |
void resize(size_type sz, const T& c);
|
| 236 |
```
|
| 237 |
|
| 238 |
+
*Effects:* As if by:
|
| 239 |
|
| 240 |
``` cpp
|
| 241 |
if (sz > size())
|
| 242 |
insert(end(), sz-size(), c);
|
| 243 |
else if (sz < size()) {
|
|
|
|
| 260 |
template <class InputIterator>
|
| 261 |
iterator insert(const_iterator position, InputIterator first,
|
| 262 |
InputIterator last);
|
| 263 |
iterator insert(const_iterator position, initializer_list<T>);
|
| 264 |
|
| 265 |
+
template <class... Args> reference emplace_front(Args&&... args);
|
| 266 |
+
template <class... Args> reference emplace_back(Args&&... args);
|
| 267 |
template <class... Args> iterator emplace(const_iterator position, Args&&... args);
|
| 268 |
void push_front(const T& x);
|
| 269 |
void push_front(T&& x);
|
| 270 |
void push_back(const T& x);
|
| 271 |
void push_back(T&& x);
|
|
|
|
| 329 |
``` cpp
|
| 330 |
void splice(const_iterator position, list& x, const_iterator i);
|
| 331 |
void splice(const_iterator position, list&& x, const_iterator i);
|
| 332 |
```
|
| 333 |
|
| 334 |
+
*Requires:* `i` is a valid dereferenceable iterator of `x`.
|
| 335 |
+
|
| 336 |
*Effects:* Inserts an element pointed to by `i` from list `x` before
|
| 337 |
`position` and removes the element from `x`. The result is unchanged if
|
| 338 |
`position == i` or `position == ++i`. Pointers and references to `*i`
|
| 339 |
continue to refer to this same element but as a member of `*this`.
|
| 340 |
Iterators to `*i` (including `i` itself) continue to refer to the same
|
| 341 |
element, but now behave as iterators into `*this`, not into `x`.
|
| 342 |
|
|
|
|
|
|
|
| 343 |
*Throws:* Nothing.
|
| 344 |
|
| 345 |
*Complexity:* Constant time.
|
| 346 |
|
| 347 |
``` cpp
|
|
|
|
| 349 |
const_iterator last);
|
| 350 |
void splice(const_iterator position, list&& x, const_iterator first,
|
| 351 |
const_iterator last);
|
| 352 |
```
|
| 353 |
|
| 354 |
+
*Requires:* `[first, last)` is a valid range in `x`. The program has
|
| 355 |
+
undefined behavior if `position` is an iterator in the range \[`first`,
|
| 356 |
+
`last`).
|
| 357 |
+
|
| 358 |
*Effects:* Inserts elements in the range \[`first`, `last`) before
|
| 359 |
+
`position` and removes the elements from `x`. Pointers and references to
|
| 360 |
+
the moved elements of `x` now refer to those same elements but as
|
| 361 |
+
members of `*this`. Iterators referring to the moved elements will
|
| 362 |
+
continue to refer to their elements, but they now behave as iterators
|
| 363 |
+
into `*this`, not into `x`.
|
|
|
|
|
|
|
|
|
|
| 364 |
|
| 365 |
*Throws:* Nothing.
|
| 366 |
|
| 367 |
*Complexity:* Constant time if `&x == this`; otherwise, linear time.
|
| 368 |
|
|
|
|
| 417 |
*Effects:* If `(&x == this)` does nothing; otherwise, merges the two
|
| 418 |
sorted ranges `[begin(), end())` and `[x.begin(), x.end())`. The result
|
| 419 |
is a range in which the elements will be sorted in non-decreasing order
|
| 420 |
according to the ordering defined by `comp`; that is, for every iterator
|
| 421 |
`i`, in the range other than the first, the condition
|
| 422 |
+
`comp(*i, *(i - 1))` will be `false`. Pointers and references to the
|
| 423 |
+
moved elements of `x` now refer to those same elements but as members of
|
| 424 |
`*this`. Iterators referring to the moved elements will continue to
|
| 425 |
refer to their elements, but they now behave as iterators into `*this`,
|
| 426 |
not into `x`.
|
| 427 |
|
| 428 |
*Remarks:* Stable ([[algorithm.stable]]). If `(&x != this)` the range
|
| 429 |
`[x.begin(), x.end())` is empty after the merge. No elements are copied
|
| 430 |
by this operation. The behavior is undefined if
|
| 431 |
+
`get_allocator() != x.get_allocator()`.
|
| 432 |
|
| 433 |
*Complexity:* At most `size() + x.size() - 1` applications of `comp` if
|
| 434 |
`(&x != this)`; otherwise, no applications of `comp` are performed. If
|
| 435 |
an exception is thrown other than by a comparison there are no effects.
|
| 436 |
|
|
|
|
| 450 |
|
| 451 |
*Requires:* `operator<` (for the first version) or `comp` (for the
|
| 452 |
second version) shall define a strict weak ordering ([[alg.sorting]]).
|
| 453 |
|
| 454 |
*Effects:* Sorts the list according to the `operator<` or a `Compare`
|
| 455 |
+
function object. If an exception is thrown, the order of the elements in
|
| 456 |
+
`*this` is unspecified. Does not affect the validity of iterators and
|
| 457 |
references.
|
| 458 |
|
| 459 |
*Remarks:* Stable ([[algorithm.stable]]).
|
| 460 |
|
| 461 |
+
*Complexity:* Approximately N log N comparisons, where `N == size()`.
|
| 462 |
|
| 463 |
#### `list` specialized algorithms <a id="list.special">[[list.special]]</a>
|
| 464 |
|
| 465 |
``` cpp
|
| 466 |
template <class T, class Allocator>
|
| 467 |
+
void swap(list<T, Allocator>& x, list<T, Allocator>& y)
|
| 468 |
+
noexcept(noexcept(x.swap(y)));
|
| 469 |
```
|
| 470 |
|
| 471 |
+
*Effects:* As if by `x.swap(y)`.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 472 |
|