From Jason Turner

[forwardlist.overview]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp1on6u4su/{from.md → to.md} +0 -156
tmp/tmp1on6u4su/{from.md → to.md} RENAMED
@@ -1,156 +0,0 @@
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
27
- be open at the beginning. — *end note*]
28
-
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&;
40
- using const_reference = const value_type&;
41
- using size_type = implementation-defined; // see [container.requirements]
42
- using difference_type = implementation-defined; // see [container.requirements]
43
- using iterator = implementation-defined // type of forward_list::iterator; // see [container.requirements]
44
- using const_iterator = implementation-defined // type of forward_list::const_iterator; // see [container.requirements]
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());
58
- ~forward_list();
59
- forward_list& operator=(const forward_list& x);
60
- forward_list& operator=(forward_list&& x)
61
- noexcept(allocator_traits<Allocator>::is_always_equal::value);
62
- forward_list& operator=(initializer_list<T>);
63
- template<class InputIterator>
64
- void assign(InputIterator first, InputIterator last);
65
- void assign(size_type n, const T& t);
66
- void assign(initializer_list<T>);
67
- allocator_type get_allocator() const noexcept;
68
-
69
- // [forwardlist.iter], iterators
70
- iterator before_begin() noexcept;
71
- const_iterator before_begin() const noexcept;
72
- iterator begin() noexcept;
73
- const_iterator begin() const noexcept;
74
- iterator end() noexcept;
75
- const_iterator end() const noexcept;
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;
88
-
89
- // [forwardlist.modifiers], modifiers
90
- template<class... Args> reference emplace_front(Args&&... args);
91
- void push_front(const T& x);
92
- void push_front(T&& x);
93
- void pop_front();
94
-
95
- template<class... Args> iterator emplace_after(const_iterator position, Args&&... args);
96
- iterator insert_after(const_iterator position, const T& x);
97
- iterator insert_after(const_iterator position, T&& x);
98
-
99
- iterator insert_after(const_iterator position, size_type n, const T& x);
100
- template<class InputIterator>
101
- iterator insert_after(const_iterator position, InputIterator first, InputIterator last);
102
- iterator insert_after(const_iterator position, initializer_list<T> il);
103
-
104
- iterator erase_after(const_iterator position);
105
- iterator erase_after(const_iterator position, const_iterator last);
106
- void swap(forward_list&)
107
- noexcept(allocator_traits<Allocator>::is_always_equal::value);
108
-
109
- void resize(size_type sz);
110
- void resize(size_type sz, const value_type& c);
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);
133
-
134
- void sort();
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
-