tmp/tmpurnhu_v5/{from.md → to.md}
RENAMED
|
@@ -1,27 +1,26 @@
|
|
| 1 |
-
####
|
| 2 |
|
| 3 |
A `forward_list` is a container that supports forward iterators and
|
| 4 |
allows constant time insert and erase operations anywhere within the
|
| 5 |
sequence, with storage management handled automatically. Fast random
|
| 6 |
access to list elements is not supported.
|
| 7 |
|
| 8 |
[*Note 1*: It is intended that `forward_list` have zero space or time
|
| 9 |
overhead relative to a hand-written C-style singly linked list. Features
|
| 10 |
that would conflict with that goal have been omitted. — *end note*]
|
| 11 |
|
| 12 |
-
A `forward_list`
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
(
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
table or for operations where there is additional semantic information.
|
| 23 |
|
| 24 |
[*Note 2*: Modifying any list requires access to the element preceding
|
| 25 |
the first element of interest, but in a `forward_list` there is no
|
| 26 |
constant-time way to access a preceding element. For this reason, ranges
|
| 27 |
that are modified, such as those supplied to `erase` and `splice`, must
|
|
@@ -30,11 +29,11 @@ be open at the beginning. — *end note*]
|
|
| 30 |
``` cpp
|
| 31 |
namespace std {
|
| 32 |
template<class T, class Allocator = allocator<T>>
|
| 33 |
class forward_list {
|
| 34 |
public:
|
| 35 |
-
// types
|
| 36 |
using value_type = T;
|
| 37 |
using allocator_type = Allocator;
|
| 38 |
using pointer = typename allocator_traits<Allocator>::pointer;
|
| 39 |
using const_pointer = typename allocator_traits<Allocator>::const_pointer;
|
| 40 |
using reference = value_type&;
|
|
@@ -46,15 +45,13 @@ namespace std {
|
|
| 46 |
|
| 47 |
// [forwardlist.cons], construct/copy/destroy
|
| 48 |
forward_list() : forward_list(Allocator()) { }
|
| 49 |
explicit forward_list(const Allocator&);
|
| 50 |
explicit forward_list(size_type n, const Allocator& = Allocator());
|
| 51 |
-
forward_list(size_type n, const T& value,
|
| 52 |
-
const Allocator& = Allocator());
|
| 53 |
template<class InputIterator>
|
| 54 |
-
forward_list(InputIterator first, InputIterator last,
|
| 55 |
-
const Allocator& = Allocator());
|
| 56 |
forward_list(const forward_list& x);
|
| 57 |
forward_list(forward_list&& x);
|
| 58 |
forward_list(const forward_list& x, const Allocator&);
|
| 59 |
forward_list(forward_list&& x, const Allocator&);
|
| 60 |
forward_list(initializer_list<T>, const Allocator& = Allocator());
|
|
@@ -79,12 +76,12 @@ namespace std {
|
|
| 79 |
|
| 80 |
const_iterator cbegin() const noexcept;
|
| 81 |
const_iterator cbefore_begin() const noexcept;
|
| 82 |
const_iterator cend() const noexcept;
|
| 83 |
|
| 84 |
-
// capacity
|
| 85 |
-
bool
|
| 86 |
size_type max_size() const noexcept;
|
| 87 |
|
| 88 |
// [forwardlist.access], element access
|
| 89 |
reference front();
|
| 90 |
const_reference front() const;
|
|
@@ -114,24 +111,22 @@ namespace std {
|
|
| 114 |
void clear() noexcept;
|
| 115 |
|
| 116 |
// [forwardlist.ops], forward_list operations
|
| 117 |
void splice_after(const_iterator position, forward_list& x);
|
| 118 |
void splice_after(const_iterator position, forward_list&& x);
|
| 119 |
-
void splice_after(const_iterator position, forward_list& x,
|
| 120 |
-
|
| 121 |
-
void splice_after(const_iterator position, forward_list&& x,
|
| 122 |
-
const_iterator i);
|
| 123 |
void splice_after(const_iterator position, forward_list& x,
|
| 124 |
const_iterator first, const_iterator last);
|
| 125 |
void splice_after(const_iterator position, forward_list&& x,
|
| 126 |
const_iterator first, const_iterator last);
|
| 127 |
|
| 128 |
-
|
| 129 |
-
template
|
| 130 |
|
| 131 |
-
|
| 132 |
-
template
|
| 133 |
|
| 134 |
void merge(forward_list& x);
|
| 135 |
void merge(forward_list&& x);
|
| 136 |
template<class Compare> void merge(forward_list& x, Compare comp);
|
| 137 |
template<class Compare> void merge(forward_list&& x, Compare comp);
|
|
@@ -140,36 +135,22 @@ namespace std {
|
|
| 140 |
template<class Compare> void sort(Compare comp);
|
| 141 |
|
| 142 |
void reverse() noexcept;
|
| 143 |
};
|
| 144 |
|
| 145 |
-
template<class InputIterator,
|
| 146 |
-
class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>>
|
| 147 |
forward_list(InputIterator, InputIterator, Allocator = Allocator())
|
| 148 |
-
-> forward_list<
|
| 149 |
|
| 150 |
-
|
| 151 |
-
bool operator==(const forward_list<T, Allocator>& x, const forward_list<T, Allocator>& y);
|
| 152 |
-
template <class T, class Allocator>
|
| 153 |
-
bool operator< (const forward_list<T, Allocator>& x, const forward_list<T, Allocator>& y);
|
| 154 |
-
template <class T, class Allocator>
|
| 155 |
-
bool operator!=(const forward_list<T, Allocator>& x, const forward_list<T, Allocator>& y);
|
| 156 |
-
template <class T, class Allocator>
|
| 157 |
-
bool operator> (const forward_list<T, Allocator>& x, const forward_list<T, Allocator>& y);
|
| 158 |
-
template <class T, class Allocator>
|
| 159 |
-
bool operator>=(const forward_list<T, Allocator>& x, const forward_list<T, Allocator>& y);
|
| 160 |
-
template <class T, class Allocator>
|
| 161 |
-
bool operator<=(const forward_list<T, Allocator>& x, const forward_list<T, Allocator>& y);
|
| 162 |
-
|
| 163 |
-
// [forwardlist.spec], specialized algorithms
|
| 164 |
template<class T, class Allocator>
|
| 165 |
void swap(forward_list<T, Allocator>& x, forward_list<T, Allocator>& y)
|
| 166 |
noexcept(noexcept(x.swap(y)));
|
| 167 |
}
|
| 168 |
```
|
| 169 |
|
| 170 |
An incomplete type `T` may be used when instantiating `forward_list` if
|
| 171 |
-
the allocator
|
| 172 |
-
[[allocator.requirements.completeness]]
|
| 173 |
any member of the resulting specialization of `forward_list` is
|
| 174 |
referenced.
|
| 175 |
|
|
|
|
| 1 |
+
#### Overview <a id="forwardlist.overview">[[forwardlist.overview]]</a>
|
| 2 |
|
| 3 |
A `forward_list` is a container that supports forward iterators and
|
| 4 |
allows constant time insert and erase operations anywhere within the
|
| 5 |
sequence, with storage management handled automatically. Fast random
|
| 6 |
access to list elements is not supported.
|
| 7 |
|
| 8 |
[*Note 1*: It is intended that `forward_list` have zero space or time
|
| 9 |
overhead relative to a hand-written C-style singly linked list. Features
|
| 10 |
that would conflict with that goal have been omitted. — *end note*]
|
| 11 |
|
| 12 |
+
A `forward_list` meets all of the requirements of a container (
|
| 13 |
+
[[container.req]]), except that the `size()` member function is not
|
| 14 |
+
provided and `operator==` has linear complexity. A `forward_list` also
|
| 15 |
+
meets all of the requirements for an allocator-aware container (
|
| 16 |
+
[[container.alloc.req]]). In addition, a `forward_list` provides the
|
| 17 |
+
`assign` member functions ([[container.seq.req]]) and several of the
|
| 18 |
+
optional container requirements ([[container.seq.opt]]). Descriptions
|
| 19 |
+
are provided here only for operations on `forward_list` that are not
|
| 20 |
+
described in that table or for operations where there is additional
|
| 21 |
+
semantic information.
|
|
|
|
| 22 |
|
| 23 |
[*Note 2*: Modifying any list requires access to the element preceding
|
| 24 |
the first element of interest, but in a `forward_list` there is no
|
| 25 |
constant-time way to access a preceding element. For this reason, ranges
|
| 26 |
that are modified, such as those supplied to `erase` and `splice`, must
|
|
|
|
| 29 |
``` cpp
|
| 30 |
namespace std {
|
| 31 |
template<class T, class Allocator = allocator<T>>
|
| 32 |
class forward_list {
|
| 33 |
public:
|
| 34 |
+
// types
|
| 35 |
using value_type = T;
|
| 36 |
using allocator_type = Allocator;
|
| 37 |
using pointer = typename allocator_traits<Allocator>::pointer;
|
| 38 |
using const_pointer = typename allocator_traits<Allocator>::const_pointer;
|
| 39 |
using reference = value_type&;
|
|
|
|
| 45 |
|
| 46 |
// [forwardlist.cons], construct/copy/destroy
|
| 47 |
forward_list() : forward_list(Allocator()) { }
|
| 48 |
explicit forward_list(const Allocator&);
|
| 49 |
explicit forward_list(size_type n, const Allocator& = Allocator());
|
| 50 |
+
forward_list(size_type n, const T& value, const Allocator& = Allocator());
|
|
|
|
| 51 |
template<class InputIterator>
|
| 52 |
+
forward_list(InputIterator first, InputIterator last, const Allocator& = Allocator());
|
|
|
|
| 53 |
forward_list(const forward_list& x);
|
| 54 |
forward_list(forward_list&& x);
|
| 55 |
forward_list(const forward_list& x, const Allocator&);
|
| 56 |
forward_list(forward_list&& x, const Allocator&);
|
| 57 |
forward_list(initializer_list<T>, const Allocator& = Allocator());
|
|
|
|
| 76 |
|
| 77 |
const_iterator cbegin() const noexcept;
|
| 78 |
const_iterator cbefore_begin() const noexcept;
|
| 79 |
const_iterator cend() const noexcept;
|
| 80 |
|
| 81 |
+
// capacity
|
| 82 |
+
[[nodiscard]] bool empty() const noexcept;
|
| 83 |
size_type max_size() const noexcept;
|
| 84 |
|
| 85 |
// [forwardlist.access], element access
|
| 86 |
reference front();
|
| 87 |
const_reference front() const;
|
|
|
|
| 111 |
void clear() noexcept;
|
| 112 |
|
| 113 |
// [forwardlist.ops], forward_list operations
|
| 114 |
void splice_after(const_iterator position, forward_list& x);
|
| 115 |
void splice_after(const_iterator position, forward_list&& x);
|
| 116 |
+
void splice_after(const_iterator position, forward_list& x, const_iterator i);
|
| 117 |
+
void splice_after(const_iterator position, forward_list&& x, const_iterator i);
|
|
|
|
|
|
|
| 118 |
void splice_after(const_iterator position, forward_list& x,
|
| 119 |
const_iterator first, const_iterator last);
|
| 120 |
void splice_after(const_iterator position, forward_list&& x,
|
| 121 |
const_iterator first, const_iterator last);
|
| 122 |
|
| 123 |
+
size_type remove(const T& value);
|
| 124 |
+
template<class Predicate> size_type remove_if(Predicate pred);
|
| 125 |
|
| 126 |
+
size_type unique();
|
| 127 |
+
template<class BinaryPredicate> size_type unique(BinaryPredicate binary_pred);
|
| 128 |
|
| 129 |
void merge(forward_list& x);
|
| 130 |
void merge(forward_list&& x);
|
| 131 |
template<class Compare> void merge(forward_list& x, Compare comp);
|
| 132 |
template<class Compare> void merge(forward_list&& x, Compare comp);
|
|
|
|
| 135 |
template<class Compare> void sort(Compare comp);
|
| 136 |
|
| 137 |
void reverse() noexcept;
|
| 138 |
};
|
| 139 |
|
| 140 |
+
template<class InputIterator, class Allocator = allocator<iter-value-type<InputIterator>>>
|
|
|
|
| 141 |
forward_list(InputIterator, InputIterator, Allocator = Allocator())
|
| 142 |
+
-> forward_list<iter-value-type<InputIterator>, Allocator>;
|
| 143 |
|
| 144 |
+
// swap
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 145 |
template<class T, class Allocator>
|
| 146 |
void swap(forward_list<T, Allocator>& x, forward_list<T, Allocator>& y)
|
| 147 |
noexcept(noexcept(x.swap(y)));
|
| 148 |
}
|
| 149 |
```
|
| 150 |
|
| 151 |
An incomplete type `T` may be used when instantiating `forward_list` if
|
| 152 |
+
the allocator meets the allocator completeness requirements
|
| 153 |
+
[[allocator.requirements.completeness]]. `T` shall be complete before
|
| 154 |
any member of the resulting specialization of `forward_list` is
|
| 155 |
referenced.
|
| 156 |
|