From Jason Turner

[forwardlist.overview]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpgcytvabl/{from.md → to.md} +44 -30
tmp/tmpgcytvabl/{from.md → to.md} RENAMED
@@ -1,14 +1,15 @@
1
  #### Class template `forward_list` 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. It is intended that
7
- `forward_list` have zero space or time overhead relative to a
8
- hand-written C-style singly linked list. Features that would conflict
9
- with that goal have been omitted.
 
10
 
11
  A `forward_list` satisfies all of the requirements of a container
12
  (Table  [[tab:containers.container.requirements]]), except that the
13
  `size()` member function is not provided and `operator==` has linear
14
  complexity. A `forward_list` also satisfies all of the requirements for
@@ -18,34 +19,34 @@ In addition, a `forward_list` provides the `assign` member functions
18
  optional container requirements (Table 
19
  [[tab:containers.sequence.optional]]). Descriptions are provided here
20
  only for operations on `forward_list` that are not described in that
21
  table or for operations where there is additional semantic information.
22
 
23
- Modifying any list requires access to the element preceding the first
24
- element of interest, but in a `forward_list` there is no constant-time
25
- way to access a preceding element. For this reason, ranges that are
26
- modified, such as those supplied to `erase` and `splice`, must be open
27
- at the beginning.
28
 
29
  ``` cpp
30
  namespace std {
31
  template <class T, class Allocator = allocator<T>>
32
  class forward_list {
33
  public:
34
  // types:
35
- typedef value_type& reference;
36
- typedef const value_type& const_reference;
37
- typedef implementation-defined iterator; // See [container.requirements]
38
- typedef implementation-defined const_iterator; // See [container.requirements]
39
- typedef implementation-defined size_type; // See [container.requirements]
40
- typedef implementation-defined difference_type;// See [container.requirements]
41
- typedef T value_type;
42
- typedef Allocator allocator_type;
43
- typedef typename allocator_traits<Allocator>::pointer pointer;
44
- typedef typename allocator_traits<Allocator>::const_pointer const_pointer;
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,
51
  const Allocator& = Allocator());
@@ -57,19 +58,20 @@ namespace std {
57
  forward_list(const forward_list& x, const Allocator&);
58
  forward_list(forward_list&& x, const Allocator&);
59
  forward_list(initializer_list<T>, const Allocator& = Allocator());
60
  ~forward_list();
61
  forward_list& operator=(const forward_list& x);
62
- forward_list& operator=(forward_list&& x);
 
63
  forward_list& operator=(initializer_list<T>);
64
  template <class InputIterator>
65
  void assign(InputIterator first, InputIterator last);
66
  void assign(size_type n, const T& t);
67
  void assign(initializer_list<T>);
68
  allocator_type get_allocator() const noexcept;
69
 
70
- // [forwardlist.iter], iterators:
71
  iterator before_begin() noexcept;
72
  const_iterator before_begin() const noexcept;
73
  iterator begin() noexcept;
74
  const_iterator begin() const noexcept;
75
  iterator end() noexcept;
@@ -81,16 +83,16 @@ namespace std {
81
 
82
  // capacity:
83
  bool empty() const noexcept;
84
  size_type max_size() const noexcept;
85
 
86
- // [forwardlist.access], element access:
87
  reference front();
88
  const_reference front() const;
89
 
90
- // [forwardlist.modifiers], modifiers:
91
- template <class... Args> void emplace_front(Args&&... args);
92
  void push_front(const T& x);
93
  void push_front(T&& x);
94
  void pop_front();
95
 
96
  template <class... Args> iterator emplace_after(const_iterator position, Args&&... args);
@@ -102,17 +104,18 @@ namespace std {
102
  iterator insert_after(const_iterator position, InputIterator first, InputIterator last);
103
  iterator insert_after(const_iterator position, initializer_list<T> il);
104
 
105
  iterator erase_after(const_iterator position);
106
  iterator erase_after(const_iterator position, const_iterator last);
107
- void swap(forward_list&);
 
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,
117
  const_iterator i);
118
  void splice_after(const_iterator position, forward_list&& x,
@@ -137,11 +140,15 @@ namespace std {
137
  template <class Compare> void sort(Compare comp);
138
 
139
  void reverse() noexcept;
140
  };
141
 
142
- // Comparison operators
 
 
 
 
143
  template <class T, class Allocator>
144
  bool operator==(const forward_list<T, Allocator>& x, const forward_list<T, Allocator>& y);
145
  template <class T, class Allocator>
146
  bool operator< (const forward_list<T, Allocator>& x, const forward_list<T, Allocator>& y);
147
  template <class T, class Allocator>
@@ -151,11 +158,18 @@ namespace std {
151
  template <class T, class Allocator>
152
  bool operator>=(const forward_list<T, Allocator>& x, const forward_list<T, Allocator>& y);
153
  template <class T, class Allocator>
154
  bool operator<=(const forward_list<T, Allocator>& x, const forward_list<T, Allocator>& y);
155
 
156
- // [forwardlist.spec], specialized algorithms:
157
  template <class T, class Allocator>
158
- void swap(forward_list<T,Allocator>& x, forward_list<T,Allocator>& y);
 
159
  }
160
  ```
161
 
 
 
 
 
 
 
 
1
  #### Class template `forward_list` 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` satisfies all of the requirements of a container
13
  (Table  [[tab:containers.container.requirements]]), except that the
14
  `size()` member function is not provided and `operator==` has linear
15
  complexity. A `forward_list` also satisfies all of the requirements for
 
19
  optional container requirements (Table 
20
  [[tab:containers.sequence.optional]]). Descriptions are provided here
21
  only for operations on `forward_list` that are not described in that
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
28
+ be open at the beginning. — *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; // see [container.requirements]
43
+ using difference_type = implementation-defined; // 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
+ // [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());
 
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());
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
  void assign(size_type n, const T& t);
69
  void assign(initializer_list<T>);
70
  allocator_type get_allocator() const noexcept;
71
 
72
+ // [forwardlist.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;
 
83
 
84
  // capacity:
85
  bool empty() const noexcept;
86
  size_type max_size() const noexcept;
87
 
88
+ // [forwardlist.access], element access
89
  reference front();
90
  const_reference front() const;
91
 
92
+ // [forwardlist.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
  void pop_front();
97
 
98
  template <class... Args> iterator emplace_after(const_iterator position, Args&&... args);
 
104
  iterator insert_after(const_iterator position, InputIterator first, InputIterator last);
105
  iterator insert_after(const_iterator position, initializer_list<T> il);
106
 
107
  iterator erase_after(const_iterator position);
108
  iterator erase_after(const_iterator position, const_iterator last);
109
+ void swap(forward_list&)
110
+ noexcept(allocator_traits<Allocator>::is_always_equal::value);
111
 
112
  void resize(size_type sz);
113
  void resize(size_type sz, const value_type& c);
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
  const_iterator i);
121
  void splice_after(const_iterator position, forward_list&& x,
 
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<typename iterator_traits<InputIterator>::value_type, Allocator>;
149
+
150
  template <class T, class Allocator>
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>
 
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 satisfies the allocator completeness requirements (
172
+ [[allocator.requirements.completeness]]). `T` shall be complete before
173
+ any member of the resulting specialization of `forward_list` is
174
+ referenced.
175
+