From Jason Turner

[forward.list.overview]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpmfimrkby/{from.md → to.md} +162 -0
tmp/tmpmfimrkby/{from.md → to.md} RENAMED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### Overview <a id="forward.list.overview">[[forward.list.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.reqmts]], 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.reqmts]]. In addition, a `forward_list` provides the
17
+ `assign` member functions and several of the optional sequence container
18
+ requirements [[sequence.reqmts]]. Descriptions are provided here only
19
+ for operations on `forward_list` that are not described in that table or
20
+ for operations where there is additional semantic information.
21
+
22
+ [*Note 2*: Modifying any list requires access to the element preceding
23
+ the first element of interest, but in a `forward_list` there is no
24
+ constant-time way to access a preceding element. For this reason,
25
+ `erase_after` and `splice_after` take fully-open ranges, not semi-open
26
+ ranges. — *end note*]
27
+
28
+ ``` cpp
29
+ namespace std {
30
+ template<class T, class Allocator = allocator<T>>
31
+ class forward_list {
32
+ public:
33
+ // types
34
+ using value_type = T;
35
+ using allocator_type = Allocator;
36
+ using pointer = typename allocator_traits<Allocator>::pointer;
37
+ using const_pointer = typename allocator_traits<Allocator>::const_pointer;
38
+ using reference = value_type&;
39
+ using const_reference = const value_type&;
40
+ using size_type = implementation-defined // type of forward_list::size_type; // see [container.requirements]
41
+ using difference_type = implementation-defined // type of forward_list::difference_type; // see [container.requirements]
42
+ using iterator = implementation-defined // type of forward_list::iterator; // see [container.requirements]
43
+ using const_iterator = implementation-defined // type of forward_list::const_iterator; // see [container.requirements]
44
+
45
+ // [forward.list.cons], construct/copy/destroy
46
+ forward_list() : forward_list(Allocator()) { }
47
+ explicit forward_list(const Allocator&);
48
+ explicit forward_list(size_type n, const Allocator& = Allocator());
49
+ forward_list(size_type n, const T& value, const Allocator& = Allocator());
50
+ template<class InputIterator>
51
+ forward_list(InputIterator first, InputIterator last, const Allocator& = Allocator());
52
+ template<container-compatible-range<T> R>
53
+ forward_list(from_range_t, R&& rg, const Allocator& = Allocator());
54
+ forward_list(const forward_list& x);
55
+ forward_list(forward_list&& x);
56
+ forward_list(const forward_list& x, const type_identity_t<Allocator>&);
57
+ forward_list(forward_list&& x, const type_identity_t<Allocator>&);
58
+ forward_list(initializer_list<T>, const Allocator& = Allocator());
59
+ ~forward_list();
60
+ forward_list& operator=(const forward_list& x);
61
+ forward_list& operator=(forward_list&& x)
62
+ noexcept(allocator_traits<Allocator>::is_always_equal::value);
63
+ forward_list& operator=(initializer_list<T>);
64
+ template<class InputIterator>
65
+ void assign(InputIterator first, InputIterator last);
66
+ template<container-compatible-range<T> R>
67
+ void assign_range(R&& rg);
68
+ void assign(size_type n, const T& t);
69
+ void assign(initializer_list<T>);
70
+ allocator_type get_allocator() const noexcept;
71
+
72
+ // [forward.list.iter], iterators
73
+ iterator before_begin() noexcept;
74
+ const_iterator before_begin() const noexcept;
75
+ iterator begin() noexcept;
76
+ const_iterator begin() const noexcept;
77
+ iterator end() noexcept;
78
+ const_iterator end() const noexcept;
79
+
80
+ const_iterator cbegin() const noexcept;
81
+ const_iterator cbefore_begin() const noexcept;
82
+ const_iterator cend() const noexcept;
83
+
84
+ // capacity
85
+ [[nodiscard]] bool empty() const noexcept;
86
+ size_type max_size() const noexcept;
87
+
88
+ // [forward.list.access], element access
89
+ reference front();
90
+ const_reference front() const;
91
+
92
+ // [forward.list.modifiers], modifiers
93
+ template<class... Args> reference emplace_front(Args&&... args);
94
+ void push_front(const T& x);
95
+ void push_front(T&& x);
96
+ template<container-compatible-range<T> R>
97
+ void prepend_range(R&& rg);
98
+ void pop_front();
99
+
100
+ template<class... Args> iterator emplace_after(const_iterator position, Args&&... args);
101
+ iterator insert_after(const_iterator position, const T& x);
102
+ iterator insert_after(const_iterator position, T&& x);
103
+
104
+ iterator insert_after(const_iterator position, size_type n, const T& x);
105
+ template<class InputIterator>
106
+ iterator insert_after(const_iterator position, InputIterator first, InputIterator last);
107
+ iterator insert_after(const_iterator position, initializer_list<T> il);
108
+ template<container-compatible-range<T> R>
109
+ iterator insert_range_after(const_iterator position, R&& rg);
110
+
111
+ iterator erase_after(const_iterator position);
112
+ iterator erase_after(const_iterator position, const_iterator last);
113
+ void swap(forward_list&)
114
+ noexcept(allocator_traits<Allocator>::is_always_equal::value);
115
+
116
+ void resize(size_type sz);
117
+ void resize(size_type sz, const value_type& c);
118
+ void clear() noexcept;
119
+
120
+ // [forward.list.ops], forward_list operations
121
+ void splice_after(const_iterator position, forward_list& x);
122
+ void splice_after(const_iterator position, forward_list&& x);
123
+ void splice_after(const_iterator position, forward_list& x, const_iterator i);
124
+ void splice_after(const_iterator position, forward_list&& x, const_iterator i);
125
+ void splice_after(const_iterator position, forward_list& x,
126
+ const_iterator first, const_iterator last);
127
+ void splice_after(const_iterator position, forward_list&& x,
128
+ const_iterator first, const_iterator last);
129
+
130
+ size_type remove(const T& value);
131
+ template<class Predicate> size_type remove_if(Predicate pred);
132
+
133
+ size_type unique();
134
+ template<class BinaryPredicate> size_type unique(BinaryPredicate binary_pred);
135
+
136
+ void merge(forward_list& x);
137
+ void merge(forward_list&& x);
138
+ template<class Compare> void merge(forward_list& x, Compare comp);
139
+ template<class Compare> void merge(forward_list&& x, Compare comp);
140
+
141
+ void sort();
142
+ template<class Compare> void sort(Compare comp);
143
+
144
+ void reverse() noexcept;
145
+ };
146
+
147
+ template<class InputIterator, class Allocator = allocator<iter-value-type<InputIterator>>>
148
+ forward_list(InputIterator, InputIterator, Allocator = Allocator())
149
+ -> forward_list<iter-value-type<InputIterator>, Allocator>;
150
+
151
+ template<ranges::input_range R, class Allocator = allocator<ranges::range_value_t<R>>>
152
+ forward_list(from_range_t, R&&, Allocator = Allocator())
153
+ -> forward_list<ranges::range_value_t<R>, Allocator>;
154
+ }
155
+ ```
156
+
157
+ An incomplete type `T` may be used when instantiating `forward_list` if
158
+ the allocator meets the allocator completeness requirements
159
+ [[allocator.requirements.completeness]]. `T` shall be complete before
160
+ any member of the resulting specialization of `forward_list` is
161
+ referenced.
162
+