From Jason Turner

[forward.list]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpfhwlahsh/{from.md → to.md} +141 -130
tmp/tmpfhwlahsh/{from.md → to.md} RENAMED
@@ -11,11 +11,11 @@ access to list elements is not supported.
11
  overhead relative to a hand-written C-style singly linked list. Features
12
  that would conflict with that goal have been omitted. — *end note*]
13
 
14
  A `forward_list` meets all of the requirements of a container
15
  [[container.reqmts]], except that the `size()` member function is not
16
- provided and `operator==` has linear complexity, A `forward_list` also
17
  meets all of the requirements for an allocator-aware container
18
  [[container.alloc.reqmts]]. In addition, a `forward_list` provides the
19
  `assign` member functions and several of the optional sequence container
20
  requirements [[sequence.reqmts]]. Descriptions are provided here only
21
  for operations on `forward_list` that are not described in that table or
@@ -25,127 +25,133 @@ for operations where there is additional semantic information.
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,
27
  `erase_after` and `splice_after` take fully-open ranges, not semi-open
28
  ranges. — *end note*]
29
 
 
 
 
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&;
41
  using const_reference = const value_type&;
42
  using size_type = implementation-defined // type of forward_list::size_type; // see [container.requirements]
43
  using difference_type = implementation-defined // type of forward_list::difference_type; // see [container.requirements]
44
  using iterator = implementation-defined // type of forward_list::iterator; // see [container.requirements]
45
  using const_iterator = implementation-defined // type of forward_list::const_iterator; // see [container.requirements]
46
 
47
  // [forward.list.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, const Allocator& = Allocator());
52
  template<class InputIterator>
53
- forward_list(InputIterator first, InputIterator last, const Allocator& = Allocator());
 
54
  template<container-compatible-range<T> R>
55
- forward_list(from_range_t, R&& rg, const Allocator& = Allocator());
56
- forward_list(const forward_list& x);
57
- forward_list(forward_list&& x);
58
- forward_list(const forward_list& x, const type_identity_t<Allocator>&);
59
- forward_list(forward_list&& x, const type_identity_t<Allocator>&);
60
- forward_list(initializer_list<T>, const Allocator& = Allocator());
61
- ~forward_list();
62
- forward_list& operator=(const forward_list& x);
63
- forward_list& operator=(forward_list&& x)
64
  noexcept(allocator_traits<Allocator>::is_always_equal::value);
65
- forward_list& operator=(initializer_list<T>);
66
  template<class InputIterator>
67
- void assign(InputIterator first, InputIterator last);
68
  template<container-compatible-range<T> R>
69
- void assign_range(R&& rg);
70
- void assign(size_type n, const T& t);
71
- void assign(initializer_list<T>);
72
- allocator_type get_allocator() const noexcept;
73
 
74
  // [forward.list.iter], iterators
75
- iterator before_begin() noexcept;
76
- const_iterator before_begin() const noexcept;
77
- iterator begin() noexcept;
78
- const_iterator begin() const noexcept;
79
- iterator end() noexcept;
80
- const_iterator end() const noexcept;
81
 
82
- const_iterator cbegin() const noexcept;
83
- const_iterator cbefore_begin() const noexcept;
84
- const_iterator cend() const noexcept;
85
 
86
  // capacity
87
- [[nodiscard]] bool empty() const noexcept;
88
- size_type max_size() const noexcept;
89
 
90
  // [forward.list.access], element access
91
- reference front();
92
- const_reference front() const;
93
 
94
  // [forward.list.modifiers], modifiers
95
- template<class... Args> reference emplace_front(Args&&... args);
96
- void push_front(const T& x);
97
- void push_front(T&& x);
98
  template<container-compatible-range<T> R>
99
- void prepend_range(R&& rg);
100
- void pop_front();
101
 
102
- template<class... Args> iterator emplace_after(const_iterator position, Args&&... args);
103
- iterator insert_after(const_iterator position, const T& x);
104
- iterator insert_after(const_iterator position, T&& x);
 
105
 
106
- iterator insert_after(const_iterator position, size_type n, const T& x);
107
  template<class InputIterator>
108
- iterator insert_after(const_iterator position, InputIterator first, InputIterator last);
109
- iterator insert_after(const_iterator position, initializer_list<T> il);
 
110
  template<container-compatible-range<T> R>
111
- iterator insert_range_after(const_iterator position, R&& rg);
112
 
113
- iterator erase_after(const_iterator position);
114
- iterator erase_after(const_iterator position, const_iterator last);
115
- void swap(forward_list&)
116
  noexcept(allocator_traits<Allocator>::is_always_equal::value);
117
 
118
- void resize(size_type sz);
119
- void resize(size_type sz, const value_type& c);
120
- void clear() noexcept;
121
 
122
  // [forward.list.ops], forward_list operations
123
- void splice_after(const_iterator position, forward_list& x);
124
- void splice_after(const_iterator position, forward_list&& x);
125
- void splice_after(const_iterator position, forward_list& x, const_iterator i);
126
- void splice_after(const_iterator position, forward_list&& x, const_iterator i);
127
- void splice_after(const_iterator position, forward_list& x,
128
  const_iterator first, const_iterator last);
129
- void splice_after(const_iterator position, forward_list&& x,
130
  const_iterator first, const_iterator last);
131
 
132
- size_type remove(const T& value);
133
- template<class Predicate> size_type remove_if(Predicate pred);
134
 
135
  size_type unique();
136
- template<class BinaryPredicate> size_type unique(BinaryPredicate binary_pred);
137
 
138
- void merge(forward_list& x);
139
- void merge(forward_list&& x);
140
- template<class Compare> void merge(forward_list& x, Compare comp);
141
- template<class Compare> void merge(forward_list&& x, Compare comp);
142
 
143
- void sort();
144
- template<class Compare> void sort(Compare comp);
145
 
146
- void reverse() noexcept;
147
  };
148
 
149
  template<class InputIterator, class Allocator = allocator<iter-value-type<InputIterator>>>
150
  forward_list(InputIterator, InputIterator, Allocator = Allocator())
151
  -> forward_list<iter-value-type<InputIterator>, Allocator>;
@@ -163,66 +169,66 @@ any member of the resulting specialization of `forward_list` is
163
  referenced.
164
 
165
  #### Constructors, copy, and assignment <a id="forward.list.cons">[[forward.list.cons]]</a>
166
 
167
  ``` cpp
168
- explicit forward_list(const Allocator&);
169
  ```
170
 
171
  *Effects:* Constructs an empty `forward_list` object using the specified
172
  allocator.
173
 
174
  *Complexity:* Constant.
175
 
176
  ``` cpp
177
- explicit forward_list(size_type n, const Allocator& = Allocator());
178
  ```
179
 
180
- *Preconditions:* `T` is *Cpp17DefaultInsertable* into `*this`.
181
 
182
  *Effects:* Constructs a `forward_list` object with `n` default-inserted
183
  elements using the specified allocator.
184
 
185
  *Complexity:* Linear in `n`.
186
 
187
  ``` cpp
188
- forward_list(size_type n, const T& value, const Allocator& = Allocator());
189
  ```
190
 
191
- *Preconditions:* `T` is *Cpp17CopyInsertable* into `*this`.
192
 
193
  *Effects:* Constructs a `forward_list` object with `n` copies of `value`
194
  using the specified allocator.
195
 
196
  *Complexity:* Linear in `n`.
197
 
198
  ``` cpp
199
  template<class InputIterator>
200
- forward_list(InputIterator first, InputIterator last, const Allocator& = Allocator());
201
  ```
202
 
203
  *Effects:* Constructs a `forward_list` object equal to the range
204
  \[`first`, `last`).
205
 
206
  *Complexity:* Linear in `distance(first, last)`.
207
 
208
  ``` cpp
209
  template<container-compatible-range<T> R>
210
- forward_list(from_range_t, R&& rg, const Allocator& = Allocator());
211
  ```
212
 
213
  *Effects:* Constructs a `forward_list` object with the elements of the
214
  range `rg`.
215
 
216
  *Complexity:* Linear in `ranges::distance(rg)`.
217
 
218
  #### Iterators <a id="forward.list.iter">[[forward.list.iter]]</a>
219
 
220
  ``` cpp
221
- iterator before_begin() noexcept;
222
- const_iterator before_begin() const noexcept;
223
- const_iterator cbefore_begin() const noexcept;
224
  ```
225
 
226
  *Effects:* `cbefore_begin()` is equivalent to
227
  `const_cast<forward_list const&>(*this).before_begin()`.
228
 
@@ -232,59 +238,60 @@ equal to the iterator returned by `begin()`.
232
  *Remarks:* `before_begin() == end()` shall equal `false`.
233
 
234
  #### Element access <a id="forward.list.access">[[forward.list.access]]</a>
235
 
236
  ``` cpp
237
- reference front();
238
- const_reference front() const;
239
  ```
240
 
241
  *Returns:* `*begin()`
242
 
243
  #### Modifiers <a id="forward.list.modifiers">[[forward.list.modifiers]]</a>
244
 
245
- None of the overloads of `insert_after` shall affect the validity of
246
- iterators and references, and `erase_after` shall invalidate only
247
- iterators and references to the erased elements. If an exception is
248
- thrown during `insert_after` there shall be no effect. Inserting `n`
249
- elements into a `forward_list` is linear in `n`, and the number of calls
250
- to the copy or move constructor of `T` is exactly equal to `n`. Erasing
251
- `n` elements from a `forward_list` is linear in `n` and the number of
252
- calls to the destructor of type `T` is exactly equal to `n`.
 
253
 
254
  ``` cpp
255
- template<class... Args> reference emplace_front(Args&&... args);
256
  ```
257
 
258
  *Effects:* Inserts an object of type `value_type` constructed with
259
  `value_type(std::forward<Args>(args)...)` at the beginning of the list.
260
 
261
  ``` cpp
262
- void push_front(const T& x);
263
- void push_front(T&& x);
264
  ```
265
 
266
  *Effects:* Inserts a copy of `x` at the beginning of the list.
267
 
268
  ``` cpp
269
  template<container-compatible-range<T> R>
270
- void prepend_range(R&& rg);
271
  ```
272
 
273
  *Effects:* Inserts a copy of each element of `rg` at the beginning of
274
  the list.
275
 
276
  [*Note 1*: The order of elements is not reversed. — *end note*]
277
 
278
  ``` cpp
279
- void pop_front();
280
  ```
281
 
282
  *Effects:* As if by `erase_after(before_begin())`.
283
 
284
  ``` cpp
285
- iterator insert_after(const_iterator position, const T& x);
286
  ```
287
 
288
  *Preconditions:* `T` is *Cpp17CopyInsertable* into `forward_list`.
289
  `position` is `before_begin()` or is a dereferenceable iterator in the
290
  range \[`begin()`, `end()`).
@@ -292,11 +299,11 @@ range \[`begin()`, `end()`).
292
  *Effects:* Inserts a copy of `x` after `position`.
293
 
294
  *Returns:* An iterator pointing to the copy of `x`.
295
 
296
  ``` cpp
297
- iterator insert_after(const_iterator position, T&& x);
298
  ```
299
 
300
  *Preconditions:* `T` is *Cpp17MoveInsertable* into `forward_list`.
301
  `position` is `before_begin()` or is a dereferenceable iterator in the
302
  range \[`begin()`, `end()`).
@@ -304,11 +311,11 @@ range \[`begin()`, `end()`).
304
  *Effects:* Inserts a copy of `x` after `position`.
305
 
306
  *Returns:* An iterator pointing to the copy of `x`.
307
 
308
  ``` cpp
309
- iterator insert_after(const_iterator position, size_type n, const T& x);
310
  ```
311
 
312
  *Preconditions:* `T` is *Cpp17CopyInsertable* into `forward_list`.
313
  `position` is `before_begin()` or is a dereferenceable iterator in the
314
  range \[`begin()`, `end()`).
@@ -318,11 +325,12 @@ range \[`begin()`, `end()`).
318
  *Returns:* An iterator pointing to the last inserted copy of `x`, or
319
  `position` if `n == 0` is `true`.
320
 
321
  ``` cpp
322
  template<class InputIterator>
323
- iterator insert_after(const_iterator position, InputIterator first, InputIterator last);
 
324
  ```
325
 
326
  *Preconditions:* `T` is *Cpp17EmplaceConstructible* into `forward_list`
327
  from `*first`. `position` is `before_begin()` or is a dereferenceable
328
  iterator in the range \[`begin()`, `end()`). Neither `first` nor `last`
@@ -334,11 +342,11 @@ are iterators in `*this`.
334
  *Returns:* An iterator pointing to the last inserted element, or
335
  `position` if `first == last` is `true`.
336
 
337
  ``` cpp
338
  template<container-compatible-range<T> R>
339
- iterator insert_range_after(const_iterator position, R&& rg);
340
  ```
341
 
342
  *Preconditions:* `T` is *Cpp17EmplaceConstructible* into `forward_list`
343
  from `*ranges::begin(rg)`. `position` is `before_begin()` or is a
344
  dereferenceable iterator in the range \[`begin()`, `end()`). `rg` and
@@ -349,19 +357,19 @@ dereferenceable iterator in the range \[`begin()`, `end()`). `rg` and
349
 
350
  *Returns:* An iterator pointing to the last inserted element, or
351
  `position` if `rg` is empty.
352
 
353
  ``` cpp
354
- iterator insert_after(const_iterator position, initializer_list<T> il);
355
  ```
356
 
357
  *Effects:* Equivalent to:
358
  `return insert_after(position, il.begin(), il.end());`
359
 
360
  ``` cpp
361
  template<class... Args>
362
- iterator emplace_after(const_iterator position, Args&&... args);
363
  ```
364
 
365
  *Preconditions:* `T` is *Cpp17EmplaceConstructible* into `forward_list`
366
  from `std::forward<Args>(args)...`. `position` is `before_begin()` or is
367
  a dereferenceable iterator in the range \[`begin()`, `end()`).
@@ -371,11 +379,11 @@ direct-non-list-initialized with `std::forward<Args>(args)...` after
371
  `position`.
372
 
373
  *Returns:* An iterator pointing to the new object.
374
 
375
  ``` cpp
376
- iterator erase_after(const_iterator position);
377
  ```
378
 
379
  *Preconditions:* The iterator following `position` is dereferenceable.
380
 
381
  *Effects:* Erases the element pointed to by the iterator following
@@ -385,11 +393,11 @@ iterator erase_after(const_iterator position);
385
  was erased, or `end()` if no such element exists.
386
 
387
  *Throws:* Nothing.
388
 
389
  ``` cpp
390
- iterator erase_after(const_iterator position, const_iterator last);
391
  ```
392
 
393
  *Preconditions:* All iterators in the range (`position`, `last`) are
394
  dereferenceable.
395
 
@@ -398,33 +406,33 @@ dereferenceable.
398
  *Returns:* `last`.
399
 
400
  *Throws:* Nothing.
401
 
402
  ``` cpp
403
- void resize(size_type sz);
404
  ```
405
 
406
- *Preconditions:* `T` is *Cpp17DefaultInsertable* into `*this`.
407
 
408
  *Effects:* If `sz < distance(begin(), end())`, erases the last
409
  `distance(begin(), end()) - sz` elements from the list. Otherwise,
410
  inserts `sz - distance(begin(), end())` default-inserted elements at the
411
  end of the list.
412
 
413
  ``` cpp
414
- void resize(size_type sz, const value_type& c);
415
  ```
416
 
417
- *Preconditions:* `T` is *Cpp17CopyInsertable* into `*this`.
418
 
419
  *Effects:* If `sz < distance(begin(), end())`, erases the last
420
  `distance(begin(), end()) - sz` elements from the list. Otherwise,
421
  inserts `sz - distance(begin(), end())` copies of `c` at the end of the
422
  list.
423
 
424
  ``` cpp
425
- void clear() noexcept;
426
  ```
427
 
428
  *Effects:* Erases all elements in the range \[`begin()`, `end()`).
429
 
430
  *Remarks:* Does not invalidate past-the-end iterators.
@@ -439,12 +447,12 @@ iterator into the list and `n` is an integer, are the same as those of
439
  list and `n` is an integer, means an iterator `j` such that `j + n == i`
440
  is `true`. For `merge` and `sort`, the definitions and requirements in
441
  [[alg.sorting]] apply.
442
 
443
  ``` cpp
444
- void splice_after(const_iterator position, forward_list& x);
445
- void splice_after(const_iterator position, forward_list&& x);
446
  ```
447
 
448
  *Preconditions:* `position` is `before_begin()` or is a dereferenceable
449
  iterator in the range \[`begin()`, `end()`).
450
  `get_allocator() == x.get_allocator()` is `true`. `addressof(x) != this`
@@ -459,12 +467,12 @@ now behave as iterators into `*this`, not into `x`.
459
  *Throws:* Nothing.
460
 
461
  *Complexity:* 𝑂(`distance(x.begin(), x.end())`)
462
 
463
  ``` cpp
464
- void splice_after(const_iterator position, forward_list& x, const_iterator i);
465
- void splice_after(const_iterator position, forward_list&& x, const_iterator i);
466
  ```
467
 
468
  *Preconditions:* `position` is `before_begin()` or is a dereferenceable
469
  iterator in the range \[`begin()`, `end()`). The iterator following `i`
470
  is a dereferenceable iterator in `x`.
@@ -480,13 +488,13 @@ behave as iterators into `*this`, not into `x`.
480
  *Throws:* Nothing.
481
 
482
  *Complexity:* 𝑂(1)
483
 
484
  ``` cpp
485
- void splice_after(const_iterator position, forward_list& x,
486
  const_iterator first, const_iterator last);
487
- void splice_after(const_iterator position, forward_list&& x,
488
  const_iterator first, const_iterator last);
489
  ```
490
 
491
  *Preconditions:* `position` is `before_begin()` or is a dereferenceable
492
  iterator in the range \[`begin()`, `end()`). (`first`, `last`) is a
@@ -502,12 +510,12 @@ continue to refer to their elements, but they now behave as iterators
502
  into `*this`, not into `x`.
503
 
504
  *Complexity:* 𝑂(`distance(first, last)`)
505
 
506
  ``` cpp
507
- size_type remove(const T& value);
508
- template<class Predicate> size_type remove_if(Predicate pred);
509
  ```
510
 
511
  *Effects:* Erases all the elements in the list referred to by a list
512
  iterator `i` for which the following conditions hold: `*i == value` (for
513
  `remove()`), `pred(*i)` is `true` (for `remove_if()`). Invalidates only
@@ -522,12 +530,12 @@ comparison or the predicate.
522
  corresponding predicate.
523
 
524
  *Remarks:* Stable [[algorithm.stable]].
525
 
526
  ``` cpp
527
- size_type unique();
528
- template<class BinaryPredicate> size_type unique(BinaryPredicate binary_pred);
529
  ```
530
 
531
  Let `binary_pred` be `equal_to<>{}` for the first overload.
532
 
533
  *Preconditions:* `binary_pred` is an equivalence relation.
@@ -545,14 +553,14 @@ only the iterators and references to the erased elements.
545
  *Complexity:* If `empty()` is `false`, exactly
546
  `distance(begin(), end()) - 1` applications of the corresponding
547
  predicate, otherwise no applications of the predicate.
548
 
549
  ``` cpp
550
- void merge(forward_list& x);
551
- void merge(forward_list&& x);
552
- template<class Compare> void merge(forward_list& x, Compare comp);
553
- template<class Compare> void merge(forward_list&& x, Compare comp);
554
  ```
555
 
556
  Let `comp` be `less<>` for the first two overloads.
557
 
558
  *Preconditions:* `*this` and `x` are both sorted with respect to the
@@ -574,12 +582,12 @@ performed.
574
  *Remarks:* Stable [[algorithm.stable]]. If `addressof(x) != this`, `x`
575
  is empty after the merge. No elements are copied by this operation. If
576
  an exception is thrown other than by a comparison, there are no effects.
577
 
578
  ``` cpp
579
- void sort();
580
- template<class Compare> void sort(Compare comp);
581
  ```
582
 
583
  *Effects:* Sorts the list according to the `operator<` or the `comp`
584
  function object. If an exception is thrown, the order of the elements in
585
  `*this` is unspecified. Does not affect the validity of iterators and
@@ -589,32 +597,35 @@ references.
589
  `distance(begin(), end())`.
590
 
591
  *Remarks:* Stable [[algorithm.stable]].
592
 
593
  ``` cpp
594
- void reverse() noexcept;
595
  ```
596
 
597
  *Effects:* Reverses the order of the elements in the list. Does not
598
  affect the validity of iterators and references.
599
 
600
  *Complexity:* Linear time.
601
 
602
  #### Erasure <a id="forward.list.erasure">[[forward.list.erasure]]</a>
603
 
604
  ``` cpp
605
- template<class T, class Allocator, class U>
606
- typename forward_list<T, Allocator>::size_type
607
  erase(forward_list<T, Allocator>& c, const U& value);
608
  ```
609
 
610
  *Effects:* Equivalent to:
611
- `return erase_if(c, [&](auto& elem) { return elem == value; });`
 
 
 
612
 
613
  ``` cpp
614
  template<class T, class Allocator, class Predicate>
615
- typename forward_list<T, Allocator>::size_type
616
  erase_if(forward_list<T, Allocator>& c, Predicate pred);
617
  ```
618
 
619
  *Effects:* Equivalent to: `return c.remove_if(pred);`
620
 
 
11
  overhead relative to a hand-written C-style singly linked list. Features
12
  that would conflict with that goal have been omitted. — *end note*]
13
 
14
  A `forward_list` meets all of the requirements of a container
15
  [[container.reqmts]], except that the `size()` member function is not
16
+ provided and `operator==` has linear complexity. A `forward_list` also
17
  meets all of the requirements for an allocator-aware container
18
  [[container.alloc.reqmts]]. In addition, a `forward_list` provides the
19
  `assign` member functions and several of the optional sequence container
20
  requirements [[sequence.reqmts]]. Descriptions are provided here only
21
  for operations on `forward_list` that are not described in that table or
 
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,
27
  `erase_after` and `splice_after` take fully-open ranges, not semi-open
28
  ranges. — *end note*]
29
 
30
+ The types `iterator` and `const_iterator` meet the constexpr iterator
31
+ requirements [[iterator.requirements.general]].
32
+
33
  ``` cpp
34
  namespace std {
35
  template<class T, class Allocator = allocator<T>>
36
  class forward_list {
37
  public:
38
  // types
39
  using value_type = T;
40
  using allocator_type = Allocator;
41
+ using pointer = allocator_traits<Allocator>::pointer;
42
+ using const_pointer = allocator_traits<Allocator>::const_pointer;
43
  using reference = value_type&;
44
  using const_reference = const value_type&;
45
  using size_type = implementation-defined // type of forward_list::size_type; // see [container.requirements]
46
  using difference_type = implementation-defined // type of forward_list::difference_type; // see [container.requirements]
47
  using iterator = implementation-defined // type of forward_list::iterator; // see [container.requirements]
48
  using const_iterator = implementation-defined // type of forward_list::const_iterator; // see [container.requirements]
49
 
50
  // [forward.list.cons], construct/copy/destroy
51
+ constexpr forward_list() : forward_list(Allocator()) { }
52
+ constexpr explicit forward_list(const Allocator&);
53
+ constexpr explicit forward_list(size_type n, const Allocator& = Allocator());
54
+ constexpr forward_list(size_type n, const T& value, const Allocator& = Allocator());
55
  template<class InputIterator>
56
+ constexpr forward_list(InputIterator first, InputIterator last,
57
+ const Allocator& = Allocator());
58
  template<container-compatible-range<T> R>
59
+ constexpr forward_list(from_range_t, R&& rg, const Allocator& = Allocator());
60
+ constexpr forward_list(const forward_list& x);
61
+ constexpr forward_list(forward_list&& x);
62
+ constexpr forward_list(const forward_list& x, const type_identity_t<Allocator>&);
63
+ constexpr forward_list(forward_list&& x, const type_identity_t<Allocator>&);
64
+ constexpr forward_list(initializer_list<T>, const Allocator& = Allocator());
65
+ constexpr ~forward_list();
66
+ constexpr forward_list& operator=(const forward_list& x);
67
+ constexpr forward_list& operator=(forward_list&& x)
68
  noexcept(allocator_traits<Allocator>::is_always_equal::value);
69
+ constexpr forward_list& operator=(initializer_list<T>);
70
  template<class InputIterator>
71
+ constexpr void assign(InputIterator first, InputIterator last);
72
  template<container-compatible-range<T> R>
73
+ constexpr void assign_range(R&& rg);
74
+ constexpr void assign(size_type n, const T& t);
75
+ constexpr void assign(initializer_list<T>);
76
+ constexpr allocator_type get_allocator() const noexcept;
77
 
78
  // [forward.list.iter], iterators
79
+ constexpr iterator before_begin() noexcept;
80
+ constexpr const_iterator before_begin() const noexcept;
81
+ constexpr iterator begin() noexcept;
82
+ constexpr const_iterator begin() const noexcept;
83
+ constexpr iterator end() noexcept;
84
+ constexpr const_iterator end() const noexcept;
85
 
86
+ constexpr const_iterator cbegin() const noexcept;
87
+ constexpr const_iterator cbefore_begin() const noexcept;
88
+ constexpr const_iterator cend() const noexcept;
89
 
90
  // capacity
91
+ constexpr bool empty() const noexcept;
92
+ constexpr size_type max_size() const noexcept;
93
 
94
  // [forward.list.access], element access
95
+ constexpr reference front();
96
+ constexpr const_reference front() const;
97
 
98
  // [forward.list.modifiers], modifiers
99
+ template<class... Args> constexpr reference emplace_front(Args&&... args);
100
+ constexpr void push_front(const T& x);
101
+ constexpr void push_front(T&& x);
102
  template<container-compatible-range<T> R>
103
+ constexpr void prepend_range(R&& rg);
104
+ constexpr void pop_front();
105
 
106
+ template<class... Args>
107
+ constexpr iterator emplace_after(const_iterator position, Args&&... args);
108
+ constexpr iterator insert_after(const_iterator position, const T& x);
109
+ constexpr iterator insert_after(const_iterator position, T&& x);
110
 
111
+ constexpr iterator insert_after(const_iterator position, size_type n, const T& x);
112
  template<class InputIterator>
113
+ constexpr iterator insert_after(const_iterator position,
114
+ InputIterator first, InputIterator last);
115
+ constexpr iterator insert_after(const_iterator position, initializer_list<T> il);
116
  template<container-compatible-range<T> R>
117
+ constexpr iterator insert_range_after(const_iterator position, R&& rg);
118
 
119
+ constexpr iterator erase_after(const_iterator position);
120
+ constexpr iterator erase_after(const_iterator position, const_iterator last);
121
+ constexpr void swap(forward_list&)
122
  noexcept(allocator_traits<Allocator>::is_always_equal::value);
123
 
124
+ constexpr void resize(size_type sz);
125
+ constexpr void resize(size_type sz, const value_type& c);
126
+ constexpr void clear() noexcept;
127
 
128
  // [forward.list.ops], forward_list operations
129
+ constexpr void splice_after(const_iterator position, forward_list& x);
130
+ constexpr void splice_after(const_iterator position, forward_list&& x);
131
+ constexpr void splice_after(const_iterator position, forward_list& x, const_iterator i);
132
+ constexpr void splice_after(const_iterator position, forward_list&& x, const_iterator i);
133
+ constexpr void splice_after(const_iterator position, forward_list& x,
134
  const_iterator first, const_iterator last);
135
+ constexpr void splice_after(const_iterator position, forward_list&& x,
136
  const_iterator first, const_iterator last);
137
 
138
+ constexpr size_type remove(const T& value);
139
+ template<class Predicate> constexpr size_type remove_if(Predicate pred);
140
 
141
  size_type unique();
142
+ template<class BinaryPredicate> constexpr size_type unique(BinaryPredicate binary_pred);
143
 
144
+ constexpr void merge(forward_list& x);
145
+ constexpr void merge(forward_list&& x);
146
+ template<class Compare> constexpr void merge(forward_list& x, Compare comp);
147
+ template<class Compare> constexpr void merge(forward_list&& x, Compare comp);
148
 
149
+ constexpr void sort();
150
+ template<class Compare> constexpr void sort(Compare comp);
151
 
152
+ constexpr void reverse() noexcept;
153
  };
154
 
155
  template<class InputIterator, class Allocator = allocator<iter-value-type<InputIterator>>>
156
  forward_list(InputIterator, InputIterator, Allocator = Allocator())
157
  -> forward_list<iter-value-type<InputIterator>, Allocator>;
 
169
  referenced.
170
 
171
  #### Constructors, copy, and assignment <a id="forward.list.cons">[[forward.list.cons]]</a>
172
 
173
  ``` cpp
174
+ constexpr explicit forward_list(const Allocator&);
175
  ```
176
 
177
  *Effects:* Constructs an empty `forward_list` object using the specified
178
  allocator.
179
 
180
  *Complexity:* Constant.
181
 
182
  ``` cpp
183
+ constexpr explicit forward_list(size_type n, const Allocator& = Allocator());
184
  ```
185
 
186
+ *Preconditions:* `T` is *Cpp17DefaultInsertable* into `forward_list`.
187
 
188
  *Effects:* Constructs a `forward_list` object with `n` default-inserted
189
  elements using the specified allocator.
190
 
191
  *Complexity:* Linear in `n`.
192
 
193
  ``` cpp
194
+ constexpr forward_list(size_type n, const T& value, const Allocator& = Allocator());
195
  ```
196
 
197
+ *Preconditions:* `T` is *Cpp17CopyInsertable* into `forward_list`.
198
 
199
  *Effects:* Constructs a `forward_list` object with `n` copies of `value`
200
  using the specified allocator.
201
 
202
  *Complexity:* Linear in `n`.
203
 
204
  ``` cpp
205
  template<class InputIterator>
206
+ constexpr forward_list(InputIterator first, InputIterator last, const Allocator& = Allocator());
207
  ```
208
 
209
  *Effects:* Constructs a `forward_list` object equal to the range
210
  \[`first`, `last`).
211
 
212
  *Complexity:* Linear in `distance(first, last)`.
213
 
214
  ``` cpp
215
  template<container-compatible-range<T> R>
216
+ constexpr forward_list(from_range_t, R&& rg, const Allocator& = Allocator());
217
  ```
218
 
219
  *Effects:* Constructs a `forward_list` object with the elements of the
220
  range `rg`.
221
 
222
  *Complexity:* Linear in `ranges::distance(rg)`.
223
 
224
  #### Iterators <a id="forward.list.iter">[[forward.list.iter]]</a>
225
 
226
  ``` cpp
227
+ constexpr iterator before_begin() noexcept;
228
+ constexpr const_iterator before_begin() const noexcept;
229
+ constexpr const_iterator cbefore_begin() const noexcept;
230
  ```
231
 
232
  *Effects:* `cbefore_begin()` is equivalent to
233
  `const_cast<forward_list const&>(*this).before_begin()`.
234
 
 
238
  *Remarks:* `before_begin() == end()` shall equal `false`.
239
 
240
  #### Element access <a id="forward.list.access">[[forward.list.access]]</a>
241
 
242
  ``` cpp
243
+ constexpr reference front();
244
+ constexpr const_reference front() const;
245
  ```
246
 
247
  *Returns:* `*begin()`
248
 
249
  #### Modifiers <a id="forward.list.modifiers">[[forward.list.modifiers]]</a>
250
 
251
+ The member functions in this subclause do not affect the validity of
252
+ iterators and references when inserting elements, and when erasing
253
+ elements invalidate iterators and references to the erased elements
254
+ only. If an exception is thrown by any of these member functions there
255
+ is no effect on the container. Inserting `n` elements into a
256
+ `forward_list` is linear in `n`, and the number of calls to the copy or
257
+ move constructor of `T` is exactly equal to `n`. Erasing `n` elements
258
+ from a `forward_list` is linear in `n` and the number of calls to the
259
+ destructor of type `T` is exactly equal to `n`.
260
 
261
  ``` cpp
262
+ template<class... Args> constexpr reference emplace_front(Args&&... args);
263
  ```
264
 
265
  *Effects:* Inserts an object of type `value_type` constructed with
266
  `value_type(std::forward<Args>(args)...)` at the beginning of the list.
267
 
268
  ``` cpp
269
+ constexpr void push_front(const T& x);
270
+ constexpr void push_front(T&& x);
271
  ```
272
 
273
  *Effects:* Inserts a copy of `x` at the beginning of the list.
274
 
275
  ``` cpp
276
  template<container-compatible-range<T> R>
277
+ constexpr void prepend_range(R&& rg);
278
  ```
279
 
280
  *Effects:* Inserts a copy of each element of `rg` at the beginning of
281
  the list.
282
 
283
  [*Note 1*: The order of elements is not reversed. — *end note*]
284
 
285
  ``` cpp
286
+ constexpr void pop_front();
287
  ```
288
 
289
  *Effects:* As if by `erase_after(before_begin())`.
290
 
291
  ``` cpp
292
+ constexpr iterator insert_after(const_iterator position, const T& x);
293
  ```
294
 
295
  *Preconditions:* `T` is *Cpp17CopyInsertable* into `forward_list`.
296
  `position` is `before_begin()` or is a dereferenceable iterator in the
297
  range \[`begin()`, `end()`).
 
299
  *Effects:* Inserts a copy of `x` after `position`.
300
 
301
  *Returns:* An iterator pointing to the copy of `x`.
302
 
303
  ``` cpp
304
+ constexpr iterator insert_after(const_iterator position, T&& x);
305
  ```
306
 
307
  *Preconditions:* `T` is *Cpp17MoveInsertable* into `forward_list`.
308
  `position` is `before_begin()` or is a dereferenceable iterator in the
309
  range \[`begin()`, `end()`).
 
311
  *Effects:* Inserts a copy of `x` after `position`.
312
 
313
  *Returns:* An iterator pointing to the copy of `x`.
314
 
315
  ``` cpp
316
+ constexpr iterator insert_after(const_iterator position, size_type n, const T& x);
317
  ```
318
 
319
  *Preconditions:* `T` is *Cpp17CopyInsertable* into `forward_list`.
320
  `position` is `before_begin()` or is a dereferenceable iterator in the
321
  range \[`begin()`, `end()`).
 
325
  *Returns:* An iterator pointing to the last inserted copy of `x`, or
326
  `position` if `n == 0` is `true`.
327
 
328
  ``` cpp
329
  template<class InputIterator>
330
+ constexpr iterator insert_after(const_iterator position,
331
+ InputIterator first, InputIterator last);
332
  ```
333
 
334
  *Preconditions:* `T` is *Cpp17EmplaceConstructible* into `forward_list`
335
  from `*first`. `position` is `before_begin()` or is a dereferenceable
336
  iterator in the range \[`begin()`, `end()`). Neither `first` nor `last`
 
342
  *Returns:* An iterator pointing to the last inserted element, or
343
  `position` if `first == last` is `true`.
344
 
345
  ``` cpp
346
  template<container-compatible-range<T> R>
347
+ constexpr iterator insert_range_after(const_iterator position, R&& rg);
348
  ```
349
 
350
  *Preconditions:* `T` is *Cpp17EmplaceConstructible* into `forward_list`
351
  from `*ranges::begin(rg)`. `position` is `before_begin()` or is a
352
  dereferenceable iterator in the range \[`begin()`, `end()`). `rg` and
 
357
 
358
  *Returns:* An iterator pointing to the last inserted element, or
359
  `position` if `rg` is empty.
360
 
361
  ``` cpp
362
+ constexpr iterator insert_after(const_iterator position, initializer_list<T> il);
363
  ```
364
 
365
  *Effects:* Equivalent to:
366
  `return insert_after(position, il.begin(), il.end());`
367
 
368
  ``` cpp
369
  template<class... Args>
370
+ constexpr iterator emplace_after(const_iterator position, Args&&... args);
371
  ```
372
 
373
  *Preconditions:* `T` is *Cpp17EmplaceConstructible* into `forward_list`
374
  from `std::forward<Args>(args)...`. `position` is `before_begin()` or is
375
  a dereferenceable iterator in the range \[`begin()`, `end()`).
 
379
  `position`.
380
 
381
  *Returns:* An iterator pointing to the new object.
382
 
383
  ``` cpp
384
+ constexpr iterator erase_after(const_iterator position);
385
  ```
386
 
387
  *Preconditions:* The iterator following `position` is dereferenceable.
388
 
389
  *Effects:* Erases the element pointed to by the iterator following
 
393
  was erased, or `end()` if no such element exists.
394
 
395
  *Throws:* Nothing.
396
 
397
  ``` cpp
398
+ constexpr iterator erase_after(const_iterator position, const_iterator last);
399
  ```
400
 
401
  *Preconditions:* All iterators in the range (`position`, `last`) are
402
  dereferenceable.
403
 
 
406
  *Returns:* `last`.
407
 
408
  *Throws:* Nothing.
409
 
410
  ``` cpp
411
+ constexpr void resize(size_type sz);
412
  ```
413
 
414
+ *Preconditions:* `T` is *Cpp17DefaultInsertable* into `forward_list`.
415
 
416
  *Effects:* If `sz < distance(begin(), end())`, erases the last
417
  `distance(begin(), end()) - sz` elements from the list. Otherwise,
418
  inserts `sz - distance(begin(), end())` default-inserted elements at the
419
  end of the list.
420
 
421
  ``` cpp
422
+ constexpr void resize(size_type sz, const value_type& c);
423
  ```
424
 
425
+ *Preconditions:* `T` is *Cpp17CopyInsertable* into `forward_list`.
426
 
427
  *Effects:* If `sz < distance(begin(), end())`, erases the last
428
  `distance(begin(), end()) - sz` elements from the list. Otherwise,
429
  inserts `sz - distance(begin(), end())` copies of `c` at the end of the
430
  list.
431
 
432
  ``` cpp
433
+ constexpr void clear() noexcept;
434
  ```
435
 
436
  *Effects:* Erases all elements in the range \[`begin()`, `end()`).
437
 
438
  *Remarks:* Does not invalidate past-the-end iterators.
 
447
  list and `n` is an integer, means an iterator `j` such that `j + n == i`
448
  is `true`. For `merge` and `sort`, the definitions and requirements in
449
  [[alg.sorting]] apply.
450
 
451
  ``` cpp
452
+ constexpr void splice_after(const_iterator position, forward_list& x);
453
+ constexpr void splice_after(const_iterator position, forward_list&& x);
454
  ```
455
 
456
  *Preconditions:* `position` is `before_begin()` or is a dereferenceable
457
  iterator in the range \[`begin()`, `end()`).
458
  `get_allocator() == x.get_allocator()` is `true`. `addressof(x) != this`
 
467
  *Throws:* Nothing.
468
 
469
  *Complexity:* 𝑂(`distance(x.begin(), x.end())`)
470
 
471
  ``` cpp
472
+ constexpr void splice_after(const_iterator position, forward_list& x, const_iterator i);
473
+ constexpr void splice_after(const_iterator position, forward_list&& x, const_iterator i);
474
  ```
475
 
476
  *Preconditions:* `position` is `before_begin()` or is a dereferenceable
477
  iterator in the range \[`begin()`, `end()`). The iterator following `i`
478
  is a dereferenceable iterator in `x`.
 
488
  *Throws:* Nothing.
489
 
490
  *Complexity:* 𝑂(1)
491
 
492
  ``` cpp
493
+ constexpr void splice_after(const_iterator position, forward_list& x,
494
  const_iterator first, const_iterator last);
495
+ constexpr void splice_after(const_iterator position, forward_list&& x,
496
  const_iterator first, const_iterator last);
497
  ```
498
 
499
  *Preconditions:* `position` is `before_begin()` or is a dereferenceable
500
  iterator in the range \[`begin()`, `end()`). (`first`, `last`) is a
 
510
  into `*this`, not into `x`.
511
 
512
  *Complexity:* 𝑂(`distance(first, last)`)
513
 
514
  ``` cpp
515
+ constexpr size_type remove(const T& value);
516
+ template<class Predicate> constexpr size_type remove_if(Predicate pred);
517
  ```
518
 
519
  *Effects:* Erases all the elements in the list referred to by a list
520
  iterator `i` for which the following conditions hold: `*i == value` (for
521
  `remove()`), `pred(*i)` is `true` (for `remove_if()`). Invalidates only
 
530
  corresponding predicate.
531
 
532
  *Remarks:* Stable [[algorithm.stable]].
533
 
534
  ``` cpp
535
+ constexpr size_type unique();
536
+ template<class BinaryPredicate> constexpr size_type unique(BinaryPredicate binary_pred);
537
  ```
538
 
539
  Let `binary_pred` be `equal_to<>{}` for the first overload.
540
 
541
  *Preconditions:* `binary_pred` is an equivalence relation.
 
553
  *Complexity:* If `empty()` is `false`, exactly
554
  `distance(begin(), end()) - 1` applications of the corresponding
555
  predicate, otherwise no applications of the predicate.
556
 
557
  ``` cpp
558
+ constexpr void merge(forward_list& x);
559
+ constexpr void merge(forward_list&& x);
560
+ template<class Compare> constexpr void merge(forward_list& x, Compare comp);
561
+ template<class Compare> constexpr void merge(forward_list&& x, Compare comp);
562
  ```
563
 
564
  Let `comp` be `less<>` for the first two overloads.
565
 
566
  *Preconditions:* `*this` and `x` are both sorted with respect to the
 
582
  *Remarks:* Stable [[algorithm.stable]]. If `addressof(x) != this`, `x`
583
  is empty after the merge. No elements are copied by this operation. If
584
  an exception is thrown other than by a comparison, there are no effects.
585
 
586
  ``` cpp
587
+ constexpr void sort();
588
+ template<class Compare> constexpr void sort(Compare comp);
589
  ```
590
 
591
  *Effects:* Sorts the list according to the `operator<` or the `comp`
592
  function object. If an exception is thrown, the order of the elements in
593
  `*this` is unspecified. Does not affect the validity of iterators and
 
597
  `distance(begin(), end())`.
598
 
599
  *Remarks:* Stable [[algorithm.stable]].
600
 
601
  ``` cpp
602
+ constexpr void reverse() noexcept;
603
  ```
604
 
605
  *Effects:* Reverses the order of the elements in the list. Does not
606
  affect the validity of iterators and references.
607
 
608
  *Complexity:* Linear time.
609
 
610
  #### Erasure <a id="forward.list.erasure">[[forward.list.erasure]]</a>
611
 
612
  ``` cpp
613
+ template<class T, class Allocator, class U = T>
614
+ constexpr typename forward_list<T, Allocator>::size_type
615
  erase(forward_list<T, Allocator>& c, const U& value);
616
  ```
617
 
618
  *Effects:* Equivalent to:
619
+
620
+ ``` cpp
621
+ return erase_if(c, [&](const auto& elem) -> bool { return elem == value; });
622
+ ```
623
 
624
  ``` cpp
625
  template<class T, class Allocator, class Predicate>
626
+ constexpr typename forward_list<T, Allocator>::size_type
627
  erase_if(forward_list<T, Allocator>& c, Predicate pred);
628
  ```
629
 
630
  *Effects:* Equivalent to: `return c.remove_if(pred);`
631