From Jason Turner

[stack]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp72t2v99g/{from.md → to.md} +49 -59
tmp/tmp72t2v99g/{from.md → to.md} RENAMED
@@ -3,47 +3,23 @@
3
  Any sequence container supporting operations `back()`, `push_back()` and
4
  `pop_back()` can be used to instantiate `stack`. In particular,
5
  `vector` ([[vector]]), `list` ([[list]]) and `deque` ([[deque]]) can
6
  be used.
7
 
8
- #### Header `<stack>` synopsis <a id="stack.syn">[[stack.syn]]</a>
9
-
10
- ``` cpp
11
- #include <initializer_list>
12
-
13
- namespace std {
14
-
15
- template <class T, class Container = deque<T> > class stack;
16
- template <class T, class Container>
17
- bool operator==(const stack<T, Container>& x,const stack<T, Container>& y);
18
- template <class T, class Container>
19
- bool operator< (const stack<T, Container>& x,const stack<T, Container>& y);
20
- template <class T, class Container>
21
- bool operator!=(const stack<T, Container>& x,const stack<T, Container>& y);
22
- template <class T, class Container>
23
- bool operator> (const stack<T, Container>& x,const stack<T, Container>& y);
24
- template <class T, class Container>
25
- bool operator>=(const stack<T, Container>& x,const stack<T, Container>& y);
26
- template <class T, class Container>
27
- bool operator<=(const stack<T, Container>& x,const stack<T, Container>& y);
28
- template <class T, class Container>
29
- void swap(stack<T, Container>& x, stack<T, Container>& y) noexcept(noexcept(x.swap(y)));
30
- }
31
- ```
32
-
33
  #### `stack` definition <a id="stack.defn">[[stack.defn]]</a>
34
 
35
  ``` cpp
36
  namespace std {
37
  template <class T, class Container = deque<T>>
38
  class stack {
39
  public:
40
- typedef typename Container::value_type value_type;
41
- typedef typename Container::reference reference;
42
- typedef typename Container::const_reference const_reference;
43
- typedef typename Container::size_type size_type;
44
- typedef Container container_type;
 
45
  protected:
46
  Container c;
47
 
48
  public:
49
  explicit stack(const Container&);
@@ -58,17 +34,23 @@ namespace std {
58
  size_type size() const { return c.size(); }
59
  reference top() { return c.back(); }
60
  const_reference top() const { return c.back(); }
61
  void push(const value_type& x) { c.push_back(x); }
62
  void push(value_type&& x) { c.push_back(std::move(x)); }
63
- template <class... Args> void emplace(Args&&... args)
64
- { c.emplace_back(std::forward<Args>(args)...); }
65
  void pop() { c.pop_back(); }
66
- void swap(stack& s) noexcept(noexcept(swap(c, s.c)))
67
  { using std::swap; swap(c, s.c); }
68
  };
69
 
 
 
 
 
 
 
70
  template <class T, class Container>
71
  bool operator==(const stack<T, Container>& x, const stack<T, Container>& y);
72
  template <class T, class Container>
73
  bool operator< (const stack<T, Container>& x, const stack<T, Container>& y);
74
  template <class T, class Container>
@@ -102,99 +84,87 @@ explicit stack(Container&& cont = Container());
102
 
103
  *Effects:* Initializes `c` with `std::move(cont)`.
104
 
105
  #### `stack` constructors with allocators <a id="stack.cons.alloc">[[stack.cons.alloc]]</a>
106
 
107
- If `uses_allocator<container_type, Alloc>::value` is `false` the
108
- constructors in this subclause shall not participate in overload
109
- resolution.
110
 
111
  ``` cpp
112
- template <class Alloc>
113
- explicit stack(const Alloc& a);
114
  ```
115
 
116
  *Effects:*  Initializes `c` with `a`.
117
 
118
  ``` cpp
119
- template <class Alloc>
120
- stack(const container_type& cont, const Alloc& a);
121
  ```
122
 
123
  *Effects:*  Initializes `c` with `cont` as the first argument and `a` as
124
  the second argument.
125
 
126
  ``` cpp
127
- template <class Alloc>
128
- stack(container_type&& cont, const Alloc& a);
129
  ```
130
 
131
  *Effects:*  Initializes `c` with `std::move(cont)` as the first argument
132
  and `a` as the second argument.
133
 
134
  ``` cpp
135
- template <class Alloc>
136
- stack(const stack& s, const Alloc& a);
137
  ```
138
 
139
  *Effects:*  Initializes `c` with `s.c` as the first argument and `a` as
140
  the second argument.
141
 
142
  ``` cpp
143
- template <class Alloc>
144
- stack(stack&& s, const Alloc& a);
145
  ```
146
 
147
  *Effects:*  Initializes `c` with `std::move(s.c)` as the first argument
148
  and `a` as the second argument.
149
 
150
  #### `stack` operators <a id="stack.ops">[[stack.ops]]</a>
151
 
152
  ``` cpp
153
  template <class T, class Container>
154
- bool operator==(const stack<T, Container>& x,
155
- const stack<T, Container>& y);
156
  ```
157
 
158
  *Returns:* `x.c == y.c`.
159
 
160
  ``` cpp
161
  template <class T, class Container>
162
- bool operator!=(const stack<T, Container>& x,
163
- const stack<T, Container>& y);
164
  ```
165
 
166
  *Returns:* `x.c != y.c`.
167
 
168
  ``` cpp
169
  template <class T, class Container>
170
- bool operator< (const stack<T, Container>& x,
171
- const stack<T, Container>& y);
172
  ```
173
 
174
  *Returns:* `x.c < y.c`.
175
 
176
  ``` cpp
177
  template <class T, class Container>
178
- bool operator<=(const stack<T, Container>& x,
179
- const stack<T, Container>& y);
180
  ```
181
 
182
  *Returns:* `x.c <= y.c`.
183
 
184
  ``` cpp
185
  template <class T, class Container>
186
- bool operator> (const stack<T, Container>& x,
187
- const stack<T, Container>& y);
188
  ```
189
 
190
  *Returns:* `x.c > y.c`.
191
 
192
  ``` cpp
193
  template <class T, class Container>
194
- bool operator>=(const stack<T, Container>& x,
195
- const stack<T, Container>& y);
196
  ```
197
 
198
  *Returns:* `x.c >= y.c`.
199
 
200
  #### `stack` specialized algorithms <a id="stack.special">[[stack.special]]</a>
@@ -202,26 +172,31 @@ template <class T, class Container>
202
  ``` cpp
203
  template <class T, class Container>
204
  void swap(stack<T, Container>& x, stack<T, Container>& y) noexcept(noexcept(x.swap(y)));
205
  ```
206
 
207
- *Effects:* `x.swap(y)`.
 
 
 
208
 
209
  <!-- Link reference definitions -->
210
  [alg.sorting]: algorithms.md#alg.sorting
211
  [algorithm.stable]: library.md#algorithm.stable
212
  [algorithms]: algorithms.md#algorithms
213
  [allocator.requirements]: library.md#allocator.requirements
 
214
  [allocator.traits.members]: utilities.md#allocator.traits.members
215
  [array]: #array
216
  [array.cons]: #array.cons
217
  [array.data]: #array.data
218
  [array.fill]: #array.fill
219
  [array.overview]: #array.overview
220
  [array.size]: #array.size
221
  [array.special]: #array.special
222
  [array.swap]: #array.swap
 
223
  [array.tuple]: #array.tuple
224
  [array.zero]: #array.zero
225
  [associative]: #associative
226
  [associative.general]: #associative.general
227
  [associative.map.syn]: #associative.map.syn
@@ -232,10 +207,17 @@ template <class T, class Container>
232
  [class.copy]: special.md#class.copy
233
  [class.ctor]: special.md#class.ctor
234
  [class.dtor]: special.md#class.dtor
235
  [container.adaptors]: #container.adaptors
236
  [container.adaptors.general]: #container.adaptors.general
 
 
 
 
 
 
 
237
  [container.requirements]: #container.requirements
238
  [container.requirements.dataraces]: #container.requirements.dataraces
239
  [container.requirements.general]: #container.requirements.general
240
  [containers]: #containers
241
  [containers.general]: #containers.general
@@ -244,28 +226,32 @@ template <class T, class Container>
244
  [deque.capacity]: #deque.capacity
245
  [deque.cons]: #deque.cons
246
  [deque.modifiers]: #deque.modifiers
247
  [deque.overview]: #deque.overview
248
  [deque.special]: #deque.special
 
249
  [forward.iterators]: iterators.md#forward.iterators
 
250
  [forwardlist]: #forwardlist
251
  [forwardlist.access]: #forwardlist.access
252
  [forwardlist.cons]: #forwardlist.cons
253
  [forwardlist.iter]: #forwardlist.iter
254
  [forwardlist.modifiers]: #forwardlist.modifiers
255
  [forwardlist.ops]: #forwardlist.ops
256
  [forwardlist.overview]: #forwardlist.overview
257
  [forwardlist.spec]: #forwardlist.spec
258
  [hash.requirements]: library.md#hash.requirements
259
  [iterator.requirements]: iterators.md#iterator.requirements
 
260
  [list]: #list
261
  [list.capacity]: #list.capacity
262
  [list.cons]: #list.cons
263
  [list.modifiers]: #list.modifiers
264
  [list.ops]: #list.ops
265
  [list.overview]: #list.overview
266
  [list.special]: #list.special
 
267
  [map]: #map
268
  [map.access]: #map.access
269
  [map.cons]: #map.cons
270
  [map.modifiers]: #map.modifiers
271
  [map.overview]: #map.overview
@@ -289,10 +275,11 @@ template <class T, class Container>
289
  [queue.cons.alloc]: #queue.cons.alloc
290
  [queue.defn]: #queue.defn
291
  [queue.ops]: #queue.ops
292
  [queue.special]: #queue.special
293
  [queue.syn]: #queue.syn
 
294
  [res.on.data.races]: library.md#res.on.data.races
295
  [sequence.reqmts]: #sequence.reqmts
296
  [sequences]: #sequences
297
  [sequences.general]: #sequences.general
298
  [set]: #set
@@ -305,15 +292,17 @@ template <class T, class Container>
305
  [stack.defn]: #stack.defn
306
  [stack.ops]: #stack.ops
307
  [stack.special]: #stack.special
308
  [stack.syn]: #stack.syn
309
  [strings]: strings.md#strings
 
310
  [tab:HashRequirements]: #tab:HashRequirements
311
  [tab:containers.allocatoraware]: #tab:containers.allocatoraware
312
  [tab:containers.associative.requirements]: #tab:containers.associative.requirements
313
  [tab:containers.container.requirements]: #tab:containers.container.requirements
314
  [tab:containers.lib.summary]: #tab:containers.lib.summary
 
315
  [tab:containers.optional.operations]: #tab:containers.optional.operations
316
  [tab:containers.reversible.requirements]: #tab:containers.reversible.requirements
317
  [tab:containers.sequence.optional]: #tab:containers.sequence.optional
318
  [tab:containers.sequence.requirements]: #tab:containers.sequence.requirements
319
  [temp.deduct]: temp.md#temp.deduct
@@ -349,10 +338,11 @@ template <class T, class Container>
349
  [vector.cons]: #vector.cons
350
  [vector.data]: #vector.data
351
  [vector.modifiers]: #vector.modifiers
352
  [vector.overview]: #vector.overview
353
  [vector.special]: #vector.special
 
354
 
355
  [^1]: Equality comparison is a refinement of partitioning if no two
356
  objects that compare equal fall into different partitions.
357
 
358
  [^2]: These member functions are only provided by containers whose
 
3
  Any sequence container supporting operations `back()`, `push_back()` and
4
  `pop_back()` can be used to instantiate `stack`. In particular,
5
  `vector` ([[vector]]), `list` ([[list]]) and `deque` ([[deque]]) can
6
  be used.
7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  #### `stack` definition <a id="stack.defn">[[stack.defn]]</a>
9
 
10
  ``` cpp
11
  namespace std {
12
  template <class T, class Container = deque<T>>
13
  class stack {
14
  public:
15
+ using value_type = typename Container::value_type;
16
+ using reference = typename Container::reference;
17
+ using const_reference = typename Container::const_reference;
18
+ using size_type = typename Container::size_type;
19
+ using container_type = Container;
20
+
21
  protected:
22
  Container c;
23
 
24
  public:
25
  explicit stack(const Container&);
 
34
  size_type size() const { return c.size(); }
35
  reference top() { return c.back(); }
36
  const_reference top() const { return c.back(); }
37
  void push(const value_type& x) { c.push_back(x); }
38
  void push(value_type&& x) { c.push_back(std::move(x)); }
39
+ template <class... Args>
40
+ reference emplace(Args&&... args) { return c.emplace_back(std::forward<Args>(args)...); }
41
  void pop() { c.pop_back(); }
42
+ void swap(stack& s) noexcept(is_nothrow_swappable_v<Container>)
43
  { using std::swap; swap(c, s.c); }
44
  };
45
 
46
+ template<class Container>
47
+ stack(Container) -> stack<typename Container::value_type, Container>;
48
+
49
+ template<class Container, class Allocator>
50
+ stack(Container, Allocator) -> stack<typename Container::value_type, Container>;
51
+
52
  template <class T, class Container>
53
  bool operator==(const stack<T, Container>& x, const stack<T, Container>& y);
54
  template <class T, class Container>
55
  bool operator< (const stack<T, Container>& x, const stack<T, Container>& y);
56
  template <class T, class Container>
 
84
 
85
  *Effects:* Initializes `c` with `std::move(cont)`.
86
 
87
  #### `stack` constructors with allocators <a id="stack.cons.alloc">[[stack.cons.alloc]]</a>
88
 
89
+ If `uses_allocator_v<container_type, Alloc>` is `false` the constructors
90
+ in this subclause shall not participate in overload resolution.
 
91
 
92
  ``` cpp
93
+ template <class Alloc> explicit stack(const Alloc& a);
 
94
  ```
95
 
96
  *Effects:*  Initializes `c` with `a`.
97
 
98
  ``` cpp
99
+ template <class Alloc> stack(const container_type& cont, const Alloc& a);
 
100
  ```
101
 
102
  *Effects:*  Initializes `c` with `cont` as the first argument and `a` as
103
  the second argument.
104
 
105
  ``` cpp
106
+ template <class Alloc> stack(container_type&& cont, const Alloc& a);
 
107
  ```
108
 
109
  *Effects:*  Initializes `c` with `std::move(cont)` as the first argument
110
  and `a` as the second argument.
111
 
112
  ``` cpp
113
+ template <class Alloc> stack(const stack& s, const Alloc& a);
 
114
  ```
115
 
116
  *Effects:*  Initializes `c` with `s.c` as the first argument and `a` as
117
  the second argument.
118
 
119
  ``` cpp
120
+ template <class Alloc> stack(stack&& s, const Alloc& a);
 
121
  ```
122
 
123
  *Effects:*  Initializes `c` with `std::move(s.c)` as the first argument
124
  and `a` as the second argument.
125
 
126
  #### `stack` operators <a id="stack.ops">[[stack.ops]]</a>
127
 
128
  ``` cpp
129
  template <class T, class Container>
130
+ bool operator==(const stack<T, Container>& x, const stack<T, Container>& y);
 
131
  ```
132
 
133
  *Returns:* `x.c == y.c`.
134
 
135
  ``` cpp
136
  template <class T, class Container>
137
+ bool operator!=(const stack<T, Container>& x, const stack<T, Container>& y);
 
138
  ```
139
 
140
  *Returns:* `x.c != y.c`.
141
 
142
  ``` cpp
143
  template <class T, class Container>
144
+ bool operator< (const stack<T, Container>& x, const stack<T, Container>& y);
 
145
  ```
146
 
147
  *Returns:* `x.c < y.c`.
148
 
149
  ``` cpp
150
  template <class T, class Container>
151
+ bool operator<=(const stack<T, Container>& x, const stack<T, Container>& y);
 
152
  ```
153
 
154
  *Returns:* `x.c <= y.c`.
155
 
156
  ``` cpp
157
  template <class T, class Container>
158
+ bool operator> (const stack<T, Container>& x, const stack<T, Container>& y);
 
159
  ```
160
 
161
  *Returns:* `x.c > y.c`.
162
 
163
  ``` cpp
164
  template <class T, class Container>
165
+ bool operator>=(const stack<T, Container>& x, const stack<T, Container>& y);
 
166
  ```
167
 
168
  *Returns:* `x.c >= y.c`.
169
 
170
  #### `stack` specialized algorithms <a id="stack.special">[[stack.special]]</a>
 
172
  ``` cpp
173
  template <class T, class Container>
174
  void swap(stack<T, Container>& x, stack<T, Container>& y) noexcept(noexcept(x.swap(y)));
175
  ```
176
 
177
+ *Remarks:* This function shall not participate in overload resolution
178
+ unless `is_swappable_v<Container>` is `true`.
179
+
180
+ *Effects:* As if by `x.swap(y)`.
181
 
182
  <!-- Link reference definitions -->
183
  [alg.sorting]: algorithms.md#alg.sorting
184
  [algorithm.stable]: library.md#algorithm.stable
185
  [algorithms]: algorithms.md#algorithms
186
  [allocator.requirements]: library.md#allocator.requirements
187
+ [allocator.requirements.completeness]: library.md#allocator.requirements.completeness
188
  [allocator.traits.members]: utilities.md#allocator.traits.members
189
  [array]: #array
190
  [array.cons]: #array.cons
191
  [array.data]: #array.data
192
  [array.fill]: #array.fill
193
  [array.overview]: #array.overview
194
  [array.size]: #array.size
195
  [array.special]: #array.special
196
  [array.swap]: #array.swap
197
+ [array.syn]: #array.syn
198
  [array.tuple]: #array.tuple
199
  [array.zero]: #array.zero
200
  [associative]: #associative
201
  [associative.general]: #associative.general
202
  [associative.map.syn]: #associative.map.syn
 
207
  [class.copy]: special.md#class.copy
208
  [class.ctor]: special.md#class.ctor
209
  [class.dtor]: special.md#class.dtor
210
  [container.adaptors]: #container.adaptors
211
  [container.adaptors.general]: #container.adaptors.general
212
+ [container.insert.return]: #container.insert.return
213
+ [container.node]: #container.node
214
+ [container.node.cons]: #container.node.cons
215
+ [container.node.dtor]: #container.node.dtor
216
+ [container.node.modifiers]: #container.node.modifiers
217
+ [container.node.observers]: #container.node.observers
218
+ [container.node.overview]: #container.node.overview
219
  [container.requirements]: #container.requirements
220
  [container.requirements.dataraces]: #container.requirements.dataraces
221
  [container.requirements.general]: #container.requirements.general
222
  [containers]: #containers
223
  [containers.general]: #containers.general
 
226
  [deque.capacity]: #deque.capacity
227
  [deque.cons]: #deque.cons
228
  [deque.modifiers]: #deque.modifiers
229
  [deque.overview]: #deque.overview
230
  [deque.special]: #deque.special
231
+ [deque.syn]: #deque.syn
232
  [forward.iterators]: iterators.md#forward.iterators
233
+ [forward_list.syn]: #forward_list.syn
234
  [forwardlist]: #forwardlist
235
  [forwardlist.access]: #forwardlist.access
236
  [forwardlist.cons]: #forwardlist.cons
237
  [forwardlist.iter]: #forwardlist.iter
238
  [forwardlist.modifiers]: #forwardlist.modifiers
239
  [forwardlist.ops]: #forwardlist.ops
240
  [forwardlist.overview]: #forwardlist.overview
241
  [forwardlist.spec]: #forwardlist.spec
242
  [hash.requirements]: library.md#hash.requirements
243
  [iterator.requirements]: iterators.md#iterator.requirements
244
+ [iterator.requirements.general]: iterators.md#iterator.requirements.general
245
  [list]: #list
246
  [list.capacity]: #list.capacity
247
  [list.cons]: #list.cons
248
  [list.modifiers]: #list.modifiers
249
  [list.ops]: #list.ops
250
  [list.overview]: #list.overview
251
  [list.special]: #list.special
252
+ [list.syn]: #list.syn
253
  [map]: #map
254
  [map.access]: #map.access
255
  [map.cons]: #map.cons
256
  [map.modifiers]: #map.modifiers
257
  [map.overview]: #map.overview
 
275
  [queue.cons.alloc]: #queue.cons.alloc
276
  [queue.defn]: #queue.defn
277
  [queue.ops]: #queue.ops
278
  [queue.special]: #queue.special
279
  [queue.syn]: #queue.syn
280
+ [random.access.iterators]: iterators.md#random.access.iterators
281
  [res.on.data.races]: library.md#res.on.data.races
282
  [sequence.reqmts]: #sequence.reqmts
283
  [sequences]: #sequences
284
  [sequences.general]: #sequences.general
285
  [set]: #set
 
292
  [stack.defn]: #stack.defn
293
  [stack.ops]: #stack.ops
294
  [stack.special]: #stack.special
295
  [stack.syn]: #stack.syn
296
  [strings]: strings.md#strings
297
+ [swappable.requirements]: library.md#swappable.requirements
298
  [tab:HashRequirements]: #tab:HashRequirements
299
  [tab:containers.allocatoraware]: #tab:containers.allocatoraware
300
  [tab:containers.associative.requirements]: #tab:containers.associative.requirements
301
  [tab:containers.container.requirements]: #tab:containers.container.requirements
302
  [tab:containers.lib.summary]: #tab:containers.lib.summary
303
+ [tab:containers.node.compat]: #tab:containers.node.compat
304
  [tab:containers.optional.operations]: #tab:containers.optional.operations
305
  [tab:containers.reversible.requirements]: #tab:containers.reversible.requirements
306
  [tab:containers.sequence.optional]: #tab:containers.sequence.optional
307
  [tab:containers.sequence.requirements]: #tab:containers.sequence.requirements
308
  [temp.deduct]: temp.md#temp.deduct
 
338
  [vector.cons]: #vector.cons
339
  [vector.data]: #vector.data
340
  [vector.modifiers]: #vector.modifiers
341
  [vector.overview]: #vector.overview
342
  [vector.special]: #vector.special
343
+ [vector.syn]: #vector.syn
344
 
345
  [^1]: Equality comparison is a refinement of partitioning if no two
346
  objects that compare equal fall into different partitions.
347
 
348
  [^2]: These member functions are only provided by containers whose