tmp/tmpmtfszvl9/{from.md → to.md}
RENAMED
|
@@ -1,15 +1,21 @@
|
|
| 1 |
-
####
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
``` cpp
|
| 4 |
void splice_after(const_iterator position, forward_list& x);
|
| 5 |
void splice_after(const_iterator position, forward_list&& x);
|
| 6 |
```
|
| 7 |
|
| 8 |
-
*
|
| 9 |
iterator in the range \[`begin()`, `end()`).
|
| 10 |
-
`get_allocator() == x.get_allocator()`. `
|
|
|
|
| 11 |
|
| 12 |
*Effects:* Inserts the contents of `x` after `position`, and `x` becomes
|
| 13 |
empty. Pointers and references to the moved elements of `x` now refer to
|
| 14 |
those same elements but as members of `*this`. Iterators referring to
|
| 15 |
the moved elements will continue to refer to their elements, but they
|
|
@@ -22,14 +28,14 @@ now behave as iterators into `*this`, not into `x`.
|
|
| 22 |
``` cpp
|
| 23 |
void splice_after(const_iterator position, forward_list& x, const_iterator i);
|
| 24 |
void splice_after(const_iterator position, forward_list&& x, const_iterator i);
|
| 25 |
```
|
| 26 |
|
| 27 |
-
*
|
| 28 |
iterator in the range \[`begin()`, `end()`). The iterator following `i`
|
| 29 |
is a dereferenceable iterator in `x`.
|
| 30 |
-
`get_allocator() == x.get_allocator()`.
|
| 31 |
|
| 32 |
*Effects:* Inserts the element following `i` into `*this`, following
|
| 33 |
`position`, and removes it from `x`. The result is unchanged if
|
| 34 |
`position == i` or `position == ++i`. Pointers and references to `*++i`
|
| 35 |
continue to refer to the same element but as a member of `*this`.
|
|
@@ -45,15 +51,15 @@ void splice_after(const_iterator position, forward_list& x,
|
|
| 45 |
const_iterator first, const_iterator last);
|
| 46 |
void splice_after(const_iterator position, forward_list&& x,
|
| 47 |
const_iterator first, const_iterator last);
|
| 48 |
```
|
| 49 |
|
| 50 |
-
*
|
| 51 |
iterator in the range \[`begin()`, `end()`). (`first`, `last`) is a
|
| 52 |
valid range in `x`, and all iterators in the range (`first`, `last`) are
|
| 53 |
dereferenceable. `position` is not an iterator in the range (`first`,
|
| 54 |
-
`last`). `get_allocator() == x.get_allocator()`.
|
| 55 |
|
| 56 |
*Effects:* Inserts elements in the range (`first`, `last`) after
|
| 57 |
`position` and removes the elements from `x`. Pointers and references to
|
| 58 |
the moved elements of `x` now refer to those same elements but as
|
| 59 |
members of `*this`. Iterators referring to the moved elements will
|
|
@@ -61,39 +67,43 @@ continue to refer to their elements, but they now behave as iterators
|
|
| 61 |
into `*this`, not into `x`.
|
| 62 |
|
| 63 |
*Complexity:* 𝑂(`distance(first, last)`)
|
| 64 |
|
| 65 |
``` cpp
|
| 66 |
-
|
| 67 |
-
template
|
| 68 |
```
|
| 69 |
|
| 70 |
-
*Effects:* Erases all the elements in the list referred by a list
|
| 71 |
iterator `i` for which the following conditions hold: `*i == value` (for
|
| 72 |
`remove()`), `pred(*i)` is `true` (for `remove_if()`). Invalidates only
|
| 73 |
the iterators and references to the erased elements.
|
| 74 |
|
|
|
|
|
|
|
| 75 |
*Throws:* Nothing unless an exception is thrown by the equality
|
| 76 |
comparison or the predicate.
|
| 77 |
|
| 78 |
-
*Remarks:* Stable
|
| 79 |
|
| 80 |
*Complexity:* Exactly `distance(begin(), end())` applications of the
|
| 81 |
corresponding predicate.
|
| 82 |
|
| 83 |
``` cpp
|
| 84 |
-
|
| 85 |
-
template
|
| 86 |
```
|
| 87 |
|
| 88 |
*Effects:* Erases all but the first element from every consecutive group
|
| 89 |
of equal elements referred to by the iterator `i` in the range
|
| 90 |
\[`first + 1`, `last`) for which `*i == *(i-1)` (for the version with no
|
| 91 |
arguments) or `pred(*i, *(i - 1))` (for the version with a predicate
|
| 92 |
argument) holds. Invalidates only the iterators and references to the
|
| 93 |
erased elements.
|
| 94 |
|
|
|
|
|
|
|
| 95 |
*Throws:* Nothing unless an exception is thrown by the equality
|
| 96 |
comparison or the predicate.
|
| 97 |
|
| 98 |
*Complexity:* If the range \[`first`, `last`) is not empty, exactly
|
| 99 |
`(last - first) - 1` applications of the corresponding predicate,
|
|
@@ -104,44 +114,40 @@ void merge(forward_list& x);
|
|
| 104 |
void merge(forward_list&& x);
|
| 105 |
template<class Compare> void merge(forward_list& x, Compare comp);
|
| 106 |
template<class Compare> void merge(forward_list&& x, Compare comp);
|
| 107 |
```
|
| 108 |
|
| 109 |
-
*
|
| 110 |
-
|
| 111 |
-
`get_allocator() == x.get_allocator()`
|
|
|
|
| 112 |
|
| 113 |
*Effects:* Merges the two sorted ranges `[begin(), end())` and
|
| 114 |
`[x.begin(), x.end())`. `x` is empty after the merge. If an exception is
|
| 115 |
thrown other than by a comparison there are no effects. Pointers and
|
| 116 |
references to the moved elements of `x` now refer to those same elements
|
| 117 |
but as members of `*this`. Iterators referring to the moved elements
|
| 118 |
will continue to refer to their elements, but they now behave as
|
| 119 |
iterators into `*this`, not into `x`.
|
| 120 |
|
| 121 |
-
*Remarks:* Stable
|
| 122 |
-
`get_allocator() != x.get_allocator()`.
|
| 123 |
|
| 124 |
*Complexity:* At most
|
| 125 |
`distance(begin(), end()) + distance(x.begin(), x.end()) - 1`
|
| 126 |
comparisons.
|
| 127 |
|
| 128 |
``` cpp
|
| 129 |
void sort();
|
| 130 |
template<class Compare> void sort(Compare comp);
|
| 131 |
```
|
| 132 |
|
| 133 |
-
*Requires:* `operator<` (for the version with no arguments) or `comp`
|
| 134 |
-
(for the version with a comparison argument) defines a strict weak
|
| 135 |
-
ordering ([[alg.sorting]]).
|
| 136 |
-
|
| 137 |
*Effects:* Sorts the list according to the `operator<` or the `comp`
|
| 138 |
function object. If an exception is thrown, the order of the elements in
|
| 139 |
`*this` is unspecified. Does not affect the validity of iterators and
|
| 140 |
references.
|
| 141 |
|
| 142 |
-
*Remarks:* Stable
|
| 143 |
|
| 144 |
*Complexity:* Approximately N log N comparisons, where N is
|
| 145 |
`distance(begin(), end())`.
|
| 146 |
|
| 147 |
``` cpp
|
|
|
|
| 1 |
+
#### Operations <a id="forwardlist.ops">[[forwardlist.ops]]</a>
|
| 2 |
+
|
| 3 |
+
In this subclause, arguments for a template parameter named `Predicate`
|
| 4 |
+
or `BinaryPredicate` shall meet the corresponding requirements in
|
| 5 |
+
[[algorithms.requirements]]. For `merge` and `sort`, the definitions and
|
| 6 |
+
requirements in [[alg.sorting]] apply.
|
| 7 |
|
| 8 |
``` cpp
|
| 9 |
void splice_after(const_iterator position, forward_list& x);
|
| 10 |
void splice_after(const_iterator position, forward_list&& x);
|
| 11 |
```
|
| 12 |
|
| 13 |
+
*Preconditions:* `position` is `before_begin()` or is a dereferenceable
|
| 14 |
iterator in the range \[`begin()`, `end()`).
|
| 15 |
+
`get_allocator() == x.get_allocator()` is `true`. `addressof(x) != this`
|
| 16 |
+
is `true`.
|
| 17 |
|
| 18 |
*Effects:* Inserts the contents of `x` after `position`, and `x` becomes
|
| 19 |
empty. Pointers and references to the moved elements of `x` now refer to
|
| 20 |
those same elements but as members of `*this`. Iterators referring to
|
| 21 |
the moved elements will continue to refer to their elements, but they
|
|
|
|
| 28 |
``` cpp
|
| 29 |
void splice_after(const_iterator position, forward_list& x, const_iterator i);
|
| 30 |
void splice_after(const_iterator position, forward_list&& x, const_iterator i);
|
| 31 |
```
|
| 32 |
|
| 33 |
+
*Preconditions:* `position` is `before_begin()` or is a dereferenceable
|
| 34 |
iterator in the range \[`begin()`, `end()`). The iterator following `i`
|
| 35 |
is a dereferenceable iterator in `x`.
|
| 36 |
+
`get_allocator() == x.get_allocator()` is `true`.
|
| 37 |
|
| 38 |
*Effects:* Inserts the element following `i` into `*this`, following
|
| 39 |
`position`, and removes it from `x`. The result is unchanged if
|
| 40 |
`position == i` or `position == ++i`. Pointers and references to `*++i`
|
| 41 |
continue to refer to the same element but as a member of `*this`.
|
|
|
|
| 51 |
const_iterator first, const_iterator last);
|
| 52 |
void splice_after(const_iterator position, forward_list&& x,
|
| 53 |
const_iterator first, const_iterator last);
|
| 54 |
```
|
| 55 |
|
| 56 |
+
*Preconditions:* `position` is `before_begin()` or is a dereferenceable
|
| 57 |
iterator in the range \[`begin()`, `end()`). (`first`, `last`) is a
|
| 58 |
valid range in `x`, and all iterators in the range (`first`, `last`) are
|
| 59 |
dereferenceable. `position` is not an iterator in the range (`first`,
|
| 60 |
+
`last`). `get_allocator() == x.get_allocator()` is `true`.
|
| 61 |
|
| 62 |
*Effects:* Inserts elements in the range (`first`, `last`) after
|
| 63 |
`position` and removes the elements from `x`. Pointers and references to
|
| 64 |
the moved elements of `x` now refer to those same elements but as
|
| 65 |
members of `*this`. Iterators referring to the moved elements will
|
|
|
|
| 67 |
into `*this`, not into `x`.
|
| 68 |
|
| 69 |
*Complexity:* 𝑂(`distance(first, last)`)
|
| 70 |
|
| 71 |
``` cpp
|
| 72 |
+
size_type remove(const T& value);
|
| 73 |
+
template<class Predicate> size_type remove_if(Predicate pred);
|
| 74 |
```
|
| 75 |
|
| 76 |
+
*Effects:* Erases all the elements in the list referred to by a list
|
| 77 |
iterator `i` for which the following conditions hold: `*i == value` (for
|
| 78 |
`remove()`), `pred(*i)` is `true` (for `remove_if()`). Invalidates only
|
| 79 |
the iterators and references to the erased elements.
|
| 80 |
|
| 81 |
+
*Returns:* The number of elements erased.
|
| 82 |
+
|
| 83 |
*Throws:* Nothing unless an exception is thrown by the equality
|
| 84 |
comparison or the predicate.
|
| 85 |
|
| 86 |
+
*Remarks:* Stable [[algorithm.stable]].
|
| 87 |
|
| 88 |
*Complexity:* Exactly `distance(begin(), end())` applications of the
|
| 89 |
corresponding predicate.
|
| 90 |
|
| 91 |
``` cpp
|
| 92 |
+
size_type unique();
|
| 93 |
+
template<class BinaryPredicate> size_type unique(BinaryPredicate pred);
|
| 94 |
```
|
| 95 |
|
| 96 |
*Effects:* Erases all but the first element from every consecutive group
|
| 97 |
of equal elements referred to by the iterator `i` in the range
|
| 98 |
\[`first + 1`, `last`) for which `*i == *(i-1)` (for the version with no
|
| 99 |
arguments) or `pred(*i, *(i - 1))` (for the version with a predicate
|
| 100 |
argument) holds. Invalidates only the iterators and references to the
|
| 101 |
erased elements.
|
| 102 |
|
| 103 |
+
*Returns:* The number of elements erased.
|
| 104 |
+
|
| 105 |
*Throws:* Nothing unless an exception is thrown by the equality
|
| 106 |
comparison or the predicate.
|
| 107 |
|
| 108 |
*Complexity:* If the range \[`first`, `last`) is not empty, exactly
|
| 109 |
`(last - first) - 1` applications of the corresponding predicate,
|
|
|
|
| 114 |
void merge(forward_list&& x);
|
| 115 |
template<class Compare> void merge(forward_list& x, Compare comp);
|
| 116 |
template<class Compare> void merge(forward_list&& x, Compare comp);
|
| 117 |
```
|
| 118 |
|
| 119 |
+
*Preconditions:* `*this` and `x` are both sorted with respect to the
|
| 120 |
+
comparator `operator<` (for the first two overloads) or `comp` (for the
|
| 121 |
+
last two overloads), and `get_allocator() == x.get_allocator()` is
|
| 122 |
+
`true`.
|
| 123 |
|
| 124 |
*Effects:* Merges the two sorted ranges `[begin(), end())` and
|
| 125 |
`[x.begin(), x.end())`. `x` is empty after the merge. If an exception is
|
| 126 |
thrown other than by a comparison there are no effects. Pointers and
|
| 127 |
references to the moved elements of `x` now refer to those same elements
|
| 128 |
but as members of `*this`. Iterators referring to the moved elements
|
| 129 |
will continue to refer to their elements, but they now behave as
|
| 130 |
iterators into `*this`, not into `x`.
|
| 131 |
|
| 132 |
+
*Remarks:* Stable [[algorithm.stable]].
|
|
|
|
| 133 |
|
| 134 |
*Complexity:* At most
|
| 135 |
`distance(begin(), end()) + distance(x.begin(), x.end()) - 1`
|
| 136 |
comparisons.
|
| 137 |
|
| 138 |
``` cpp
|
| 139 |
void sort();
|
| 140 |
template<class Compare> void sort(Compare comp);
|
| 141 |
```
|
| 142 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 143 |
*Effects:* Sorts the list according to the `operator<` or the `comp`
|
| 144 |
function object. If an exception is thrown, the order of the elements in
|
| 145 |
`*this` is unspecified. Does not affect the validity of iterators and
|
| 146 |
references.
|
| 147 |
|
| 148 |
+
*Remarks:* Stable [[algorithm.stable]].
|
| 149 |
|
| 150 |
*Complexity:* Approximately N log N comparisons, where N is
|
| 151 |
`distance(begin(), end())`.
|
| 152 |
|
| 153 |
``` cpp
|