tmp/tmpr43n1817/{from.md → to.md}
RENAMED
|
@@ -1,31 +1,29 @@
|
|
| 1 |
-
####
|
| 2 |
|
| 3 |
A `list` is a sequence container that supports bidirectional iterators
|
| 4 |
and allows constant time insert and erase operations anywhere within the
|
| 5 |
-
sequence, with storage management handled automatically. Unlike
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
access anyway.
|
| 9 |
|
| 10 |
-
A `list`
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
one of these tables or for operations where there is additional semantic
|
| 19 |
information.
|
| 20 |
|
| 21 |
``` cpp
|
| 22 |
namespace std {
|
| 23 |
template<class T, class Allocator = allocator<T>>
|
| 24 |
class list {
|
| 25 |
public:
|
| 26 |
-
// types
|
| 27 |
using value_type = T;
|
| 28 |
using allocator_type = Allocator;
|
| 29 |
using pointer = typename allocator_traits<Allocator>::pointer;
|
| 30 |
using const_pointer = typename allocator_traits<Allocator>::const_pointer;
|
| 31 |
using reference = value_type&;
|
|
@@ -58,11 +56,11 @@ namespace std {
|
|
| 58 |
void assign(InputIterator first, InputIterator last);
|
| 59 |
void assign(size_type n, const T& t);
|
| 60 |
void assign(initializer_list<T>);
|
| 61 |
allocator_type get_allocator() const noexcept;
|
| 62 |
|
| 63 |
-
// iterators
|
| 64 |
iterator begin() noexcept;
|
| 65 |
const_iterator begin() const noexcept;
|
| 66 |
iterator end() noexcept;
|
| 67 |
const_iterator end() const noexcept;
|
| 68 |
reverse_iterator rbegin() noexcept;
|
|
@@ -74,17 +72,17 @@ namespace std {
|
|
| 74 |
const_iterator cend() const noexcept;
|
| 75 |
const_reverse_iterator crbegin() const noexcept;
|
| 76 |
const_reverse_iterator crend() const noexcept;
|
| 77 |
|
| 78 |
// [list.capacity], capacity
|
| 79 |
-
bool
|
| 80 |
size_type size() const noexcept;
|
| 81 |
size_type max_size() const noexcept;
|
| 82 |
void resize(size_type sz);
|
| 83 |
void resize(size_type sz, const T& c);
|
| 84 |
|
| 85 |
-
// element access
|
| 86 |
reference front();
|
| 87 |
const_reference front() const;
|
| 88 |
reference back();
|
| 89 |
const_reference back() const;
|
| 90 |
|
|
@@ -101,36 +99,32 @@ namespace std {
|
|
| 101 |
template<class... Args> iterator emplace(const_iterator position, Args&&... args);
|
| 102 |
iterator insert(const_iterator position, const T& x);
|
| 103 |
iterator insert(const_iterator position, T&& x);
|
| 104 |
iterator insert(const_iterator position, size_type n, const T& x);
|
| 105 |
template<class InputIterator>
|
| 106 |
-
iterator insert(const_iterator position, InputIterator first,
|
| 107 |
-
InputIterator last);
|
| 108 |
iterator insert(const_iterator position, initializer_list<T> il);
|
| 109 |
|
| 110 |
iterator erase(const_iterator position);
|
| 111 |
iterator erase(const_iterator position, const_iterator last);
|
| 112 |
-
void swap(list&)
|
| 113 |
-
noexcept(allocator_traits<Allocator>::is_always_equal::value);
|
| 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,
|
| 122 |
-
|
| 123 |
-
void splice(const_iterator position, list&& x,
|
| 124 |
-
const_iterator first, const_iterator last);
|
| 125 |
|
| 126 |
-
|
| 127 |
-
template
|
| 128 |
|
| 129 |
-
|
| 130 |
template<class BinaryPredicate>
|
| 131 |
-
|
| 132 |
|
| 133 |
void merge(list& x);
|
| 134 |
void merge(list&& x);
|
| 135 |
template<class Compare> void merge(list& x, Compare comp);
|
| 136 |
template<class Compare> void merge(list&& x, Compare comp);
|
|
@@ -139,35 +133,21 @@ namespace std {
|
|
| 139 |
template<class Compare> void sort(Compare comp);
|
| 140 |
|
| 141 |
void reverse() noexcept;
|
| 142 |
};
|
| 143 |
|
| 144 |
-
template<class InputIterator,
|
| 145 |
-
class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>>
|
| 146 |
list(InputIterator, InputIterator, Allocator = Allocator())
|
| 147 |
-
-> list<
|
| 148 |
|
| 149 |
-
|
| 150 |
-
bool operator==(const list<T, Allocator>& x, const list<T, Allocator>& y);
|
| 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>
|
| 156 |
-
bool operator> (const list<T, Allocator>& x, const list<T, Allocator>& y);
|
| 157 |
-
template <class T, class Allocator>
|
| 158 |
-
bool operator>=(const list<T, Allocator>& x, const list<T, Allocator>& y);
|
| 159 |
-
template <class T, class Allocator>
|
| 160 |
-
bool operator<=(const list<T, Allocator>& x, const list<T, Allocator>& y);
|
| 161 |
-
|
| 162 |
-
// [list.special], specialized algorithms
|
| 163 |
template<class T, class Allocator>
|
| 164 |
void swap(list<T, Allocator>& x, list<T, Allocator>& y)
|
| 165 |
noexcept(noexcept(x.swap(y)));
|
| 166 |
}
|
| 167 |
```
|
| 168 |
|
| 169 |
An incomplete type `T` may be used when instantiating `list` if the
|
| 170 |
-
allocator
|
| 171 |
-
[[allocator.requirements.completeness]]
|
| 172 |
any member of the resulting specialization of `list` is referenced.
|
| 173 |
|
|
|
|
| 1 |
+
#### Overview <a id="list.overview">[[list.overview]]</a>
|
| 2 |
|
| 3 |
A `list` is a sequence container that supports bidirectional iterators
|
| 4 |
and allows constant time insert and erase operations anywhere within the
|
| 5 |
+
sequence, with storage management handled automatically. Unlike vectors
|
| 6 |
+
[[vector]] and deques [[deque]], fast random access to list elements is
|
| 7 |
+
not supported, but many algorithms only need sequential access anyway.
|
|
|
|
| 8 |
|
| 9 |
+
A `list` meets all of the requirements of a container, of a reversible
|
| 10 |
+
container (given in two tables in [[container.requirements]]), of a
|
| 11 |
+
sequence container, including most of the optional sequence container
|
| 12 |
+
requirements [[sequence.reqmts]], and of an allocator-aware container (
|
| 13 |
+
[[container.alloc.req]]). The exceptions are the `operator[]` and `at`
|
| 14 |
+
member functions, which are not provided.[^2] Descriptions are provided
|
| 15 |
+
here only for operations on `list` that are not described in one of
|
| 16 |
+
these tables or for operations where there is additional semantic
|
|
|
|
| 17 |
information.
|
| 18 |
|
| 19 |
``` cpp
|
| 20 |
namespace std {
|
| 21 |
template<class T, class Allocator = allocator<T>>
|
| 22 |
class list {
|
| 23 |
public:
|
| 24 |
+
// types
|
| 25 |
using value_type = T;
|
| 26 |
using allocator_type = Allocator;
|
| 27 |
using pointer = typename allocator_traits<Allocator>::pointer;
|
| 28 |
using const_pointer = typename allocator_traits<Allocator>::const_pointer;
|
| 29 |
using reference = value_type&;
|
|
|
|
| 56 |
void assign(InputIterator first, InputIterator last);
|
| 57 |
void assign(size_type n, const T& t);
|
| 58 |
void assign(initializer_list<T>);
|
| 59 |
allocator_type get_allocator() const noexcept;
|
| 60 |
|
| 61 |
+
// iterators
|
| 62 |
iterator begin() noexcept;
|
| 63 |
const_iterator begin() const noexcept;
|
| 64 |
iterator end() noexcept;
|
| 65 |
const_iterator end() const noexcept;
|
| 66 |
reverse_iterator rbegin() noexcept;
|
|
|
|
| 72 |
const_iterator cend() const noexcept;
|
| 73 |
const_reverse_iterator crbegin() const noexcept;
|
| 74 |
const_reverse_iterator crend() const noexcept;
|
| 75 |
|
| 76 |
// [list.capacity], capacity
|
| 77 |
+
[[nodiscard]] bool empty() const noexcept;
|
| 78 |
size_type size() const noexcept;
|
| 79 |
size_type max_size() const noexcept;
|
| 80 |
void resize(size_type sz);
|
| 81 |
void resize(size_type sz, const T& c);
|
| 82 |
|
| 83 |
+
// element access
|
| 84 |
reference front();
|
| 85 |
const_reference front() const;
|
| 86 |
reference back();
|
| 87 |
const_reference back() const;
|
| 88 |
|
|
|
|
| 99 |
template<class... Args> iterator emplace(const_iterator position, Args&&... args);
|
| 100 |
iterator insert(const_iterator position, const T& x);
|
| 101 |
iterator insert(const_iterator position, T&& x);
|
| 102 |
iterator insert(const_iterator position, size_type n, const T& x);
|
| 103 |
template<class InputIterator>
|
| 104 |
+
iterator insert(const_iterator position, InputIterator first, InputIterator last);
|
|
|
|
| 105 |
iterator insert(const_iterator position, initializer_list<T> il);
|
| 106 |
|
| 107 |
iterator erase(const_iterator position);
|
| 108 |
iterator erase(const_iterator position, const_iterator last);
|
| 109 |
+
void swap(list&) noexcept(allocator_traits<Allocator>::is_always_equal::value);
|
|
|
|
| 110 |
void clear() noexcept;
|
| 111 |
|
| 112 |
// [list.ops], list operations
|
| 113 |
void splice(const_iterator position, list& x);
|
| 114 |
void splice(const_iterator position, list&& x);
|
| 115 |
void splice(const_iterator position, list& x, const_iterator i);
|
| 116 |
void splice(const_iterator position, list&& x, const_iterator i);
|
| 117 |
+
void splice(const_iterator position, list& x, const_iterator first, const_iterator last);
|
| 118 |
+
void splice(const_iterator position, list&& x, const_iterator first, const_iterator last);
|
|
|
|
|
|
|
| 119 |
|
| 120 |
+
size_type remove(const T& value);
|
| 121 |
+
template<class Predicate> size_type remove_if(Predicate pred);
|
| 122 |
|
| 123 |
+
size_type unique();
|
| 124 |
template<class BinaryPredicate>
|
| 125 |
+
size_type unique(BinaryPredicate binary_pred);
|
| 126 |
|
| 127 |
void merge(list& x);
|
| 128 |
void merge(list&& x);
|
| 129 |
template<class Compare> void merge(list& x, Compare comp);
|
| 130 |
template<class Compare> void merge(list&& x, Compare comp);
|
|
|
|
| 133 |
template<class Compare> void sort(Compare comp);
|
| 134 |
|
| 135 |
void reverse() noexcept;
|
| 136 |
};
|
| 137 |
|
| 138 |
+
template<class InputIterator, class Allocator = allocator<iter-value-type<InputIterator>>>
|
|
|
|
| 139 |
list(InputIterator, InputIterator, Allocator = Allocator())
|
| 140 |
+
-> list<iter-value-type<InputIterator>, Allocator>;
|
| 141 |
|
| 142 |
+
// swap
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 143 |
template<class T, class Allocator>
|
| 144 |
void swap(list<T, Allocator>& x, list<T, Allocator>& y)
|
| 145 |
noexcept(noexcept(x.swap(y)));
|
| 146 |
}
|
| 147 |
```
|
| 148 |
|
| 149 |
An incomplete type `T` may be used when instantiating `list` if the
|
| 150 |
+
allocator meets the allocator completeness requirements
|
| 151 |
+
[[allocator.requirements.completeness]]. `T` shall be complete before
|
| 152 |
any member of the resulting specialization of `list` is referenced.
|
| 153 |
|