BDE 4.39.x Production Release
Loading...
Searching...
No Matches
bslstl_stack_cpp03.h
Go to the documentation of this file.
1/// @file bslstl_stack_cpp03.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bslstl_stack_cpp03.h -*-C++-*-
8
9// Automatically generated file. **DO NOT EDIT**
10
11#ifndef INCLUDED_BSLSTL_STACK_CPP03
12#define INCLUDED_BSLSTL_STACK_CPP03
13
14/// @defgroup bslstl_stack_cpp03 bslstl_stack_cpp03
15/// @brief Provide C++03 implementation for bslstl_stack.h
16/// @addtogroup bsl
17/// @{
18/// @addtogroup bslstl
19/// @{
20/// @addtogroup bslstl_stack_cpp03
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bslstl_stack_cpp03-purpose"> Purpose</a>
25/// * <a href="#bslstl_stack_cpp03-classes"> Classes </a>
26/// * <a href="#bslstl_stack_cpp03-description"> Description </a>
27///
28/// # Purpose {#bslstl_stack_cpp03-purpose}
29/// Provide C++03 implementation for bslstl_stack.h
30///
31/// # Classes {#bslstl_stack_cpp03-classes}
32/// See bslstl_stack.h for list of classes
33///
34/// @see bslstl_stack
35///
36/// # Description {#bslstl_stack_cpp03-description}
37/// This component is the C++03 translation of a C++11 component,
38/// generated by the 'sim_cpp11_features.pl' program. If the original header
39/// contains any specially delimited regions of C++11 code, then this generated
40/// file contains the C++03 equivalent, i.e., with variadic templates expanded
41/// and rvalue-references replaced by 'bslmf::MovableRef' objects. The header
42/// code in this file is designed to be '#include'd into the original header
43/// when compiling with a C++03 compiler. If there are no specially delimited
44/// regions of C++11 code, then this header contains no code and is not
45/// '#include'd in the original header.
46///
47/// Generated on Wed Jun 3 10:06:09 2026
48/// Command line: sim_cpp11_features.pl bslstl_stack.h
49/// @}
50/** @} */
51/** @} */
52
53/** @addtogroup bsl
54 * @{
55 */
56/** @addtogroup bslstl
57 * @{
58 */
59/** @addtogroup bslstl_stack_cpp03
60 * @{
61 */
62
63#ifdef COMPILING_BSLSTL_STACK_H
64
65namespace bsl {
66
67 // ===========
68 // class stack
69 // ===========
70
71/// This `class` defines a container adapter which supports access primarily
72/// via `push`, `pop`, and `top`. This type can be based on a variety of
73/// other container types, including `deque`, `vector`, and `list`. This
74/// type is value-semantic if the supporting `CONTAINER` and `VALUE` are
75/// value-semantic.
76///
77///
78/// \note Note that we never use `VALUE` in the implementation except in the
79/// default argument of `CONTAINER`. We use `CONTAINER::value_type` for
80/// everything, which means that if `CONTAINER` is specified, then `VALUE`
81/// is ignored.
82///
83/// See @ref bslstl_stack_cpp03
84template <class VALUE, class CONTAINER = deque<VALUE> >
85class stack {
86
87#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
88 // STATIC CHECK: Type mismatch is UB per C++17
90#endif
91
92 private:
93 // PRIVATE TYPES
94
95 /// This `typedef` is a convenient alias for the utility associated with
96 /// movable references.
97 typedef BloombergLP::bslmf::MovableRefUtil MoveUtil;
98
99 // PRIVATE MANIPULATORS
100
101 /// Push onto this stack the elements of the specified `[first, last)`
102 /// range.
103 template <class INPUT_ITER, class SENTINEL>
104 void privatePushRange(INPUT_ITER first, SENTINEL last);
105
106 public:
107 // PUBLIC TYPES
108 typedef typename CONTAINER::value_type value_type;
109 typedef typename CONTAINER::reference reference;
110 typedef typename CONTAINER::const_reference const_reference;
111 typedef typename CONTAINER::size_type size_type;
112 typedef CONTAINER container_type;
113
114
115 protected:
116 // PROTECTED DATA
117 container_type c; // We are required by the standard to have the
118 // container be a protected variable named 'c'.
119
120 private:
121 // FRIENDS
122 template <class VAL, class CONT>
123 friend bool operator==(const stack<VAL, CONT>&, const stack<VAL, CONT>&);
124 template <class VAL, class CONT>
125 friend bool operator!=(const stack<VAL, CONT>&, const stack<VAL, CONT>&);
126 template <class VAL, class CONT>
127 friend bool operator< (const stack<VAL, CONT>&, const stack<VAL, CONT>&);
128 template <class VAL, class CONT>
129 friend bool operator> (const stack<VAL, CONT>&, const stack<VAL, CONT>&);
130 template <class VAL, class CONT>
131 friend bool operator<=(const stack<VAL, CONT>&, const stack<VAL, CONT>&);
132 template <class VAL, class CONT>
133 friend bool operator>=(const stack<VAL, CONT>&, const stack<VAL, CONT>&);
134#if defined BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON \
135 && defined BSLS_LIBRARYFEATURES_HAS_CPP20_CONCEPTS
136 template <class VAL, three_way_comparable CONT>
137 friend compare_three_way_result_t<CONT>
138 operator<=>(const stack<VAL, CONT>&, const stack<VAL, CONT>&);
139#endif
140
141 public:
142 // TRAITS
144 stack,
145 BloombergLP::bslma::UsesBslmaAllocator,
146 BloombergLP::bslma::UsesBslmaAllocator<container_type>::value);
147
148 // CREATORS
149
150 /// Create an empty stack. No allocator will be provided to the
151 /// underlying container. That container's memory allocation will be
152 /// provided by the default allocator of its type.
153 explicit stack();
154
155 /// Create a stack having the value of the specified `original`. The
156 /// currently installed default allocator is used to supply memory.
157 stack(const stack& original);
158
159 /// Create a stack having the value of the specified `original` by
160 /// moving the contents of `original` to the new stack. The allocator
161 /// associated with `original` is propagated for use in the new stack.
162 /// `original` is left in a valid but unspecified state.
163 stack(BloombergLP::bslmf::MovableRef<stack> original);
164
165 /// Create a stack whose underlying container has the value of the
166 /// specified `container`. The currently installed default allocator is
167 /// used to supply memory.
168 explicit
169 stack(const CONTAINER& container);
170
171 /// Create a stack whose underlying container has the value of the
172 /// specified `container` (on entry) by moving the contents of
173 /// `container` to the new stack. The allocator associated with
174 /// `container` is propagated for use in the new stack. `container` is
175 /// left in a valid but unspecified state.
176 explicit
177 stack(BloombergLP::bslmf::MovableRef<CONTAINER> container);
178
179 /// Create an empty stack, and use the specified `basicAllocator` to
180 /// supply memory. If `CONTAINER::allocator_type` does not exist, this
181 /// constructor may not be used.
182 template <class ALLOCATOR>
183 explicit
184 stack(const ALLOCATOR& basicAllocator,
186 ALLOCATOR>::type * = 0);
187
188 /// Create a stack whose underlying container has the value of the
189 /// specified `container`, and use the specified `basicAllocator` to
190 /// supply memory. If `CONTAINER::allocator_type` does not exist, this
191 /// constructor may not be used.
192 template <class ALLOCATOR>
193 stack(const CONTAINER& container,
194 const ALLOCATOR& basicAllocator,
196 ALLOCATOR>::type * = 0);
197
198 /// Create a stack having the value of the specified stack `original`
199 /// and use the specified `basicAllocator` to supply memory. If
200 /// `CONTAINER::allocator_type` does not exist, this constructor may not
201 /// be used.
202 template <class ALLOCATOR>
203 stack(const stack& original,
204 const ALLOCATOR& basicAllocator,
206 ALLOCATOR>::type * = 0);
207
208 /// Create a stack whose underlying container has the value of the
209 /// specified `container` (on entry) that uses `basicAllocator` to
210 /// supply memory by using the allocator-extended move constructor of
211 /// `CONTAINER. `container' is left in a valid but unspecified state.
212 /// A `bslma::Allocator *` can be supplied for `basicAllocator` if the
213 /// (template parameter) `ALLOCATOR` is `bsl::allocator` (the default).
214 /// This method assumes that `CONTAINER` has a move constructor. If
215 /// `CONTAINER::allocator_type` does not exist, this constructor may not
216 /// be used.
217 template <class ALLOCATOR>
218 stack(BloombergLP::bslmf::MovableRef<CONTAINER> container,
219 const ALLOCATOR& basicAllocator,
221 ALLOCATOR>::type * = 0);
222
223 /// Create a stack having the value of the specified `original` (on
224 /// entry) that uses `basicAllocator` to supply memory by using the
225 /// allocator-extended moved constructor of `CONTAINER`. `original` is left in a valid but unspecified state.
226 ///
227 /// \note Note that a
228 /// `bslma::Allocator *` can be supplied for `basicAllocator` if the
229 /// (template parameter) `ALLOCATOR` is `bsl::allocator` (the default).
230 /// Also note that this method assumes that `CONTAINER` has a move
231 /// constructor. Also note that if `CONTAINER::allocator_type` does not
232 /// exist, this constructor may not be used.
233 template <class ALLOCATOR>
234 stack(BloombergLP::bslmf::MovableRef<stack> original,
235 const ALLOCATOR& basicAllocator,
237 ALLOCATOR>::type * = 0);
238
239 /// Create a stack passing the specified `first` and `last` to the
240 /// constructor of the underlying container. Optionally specify an
241 /// `allocator` used to supply memory. If `allocator` is not specified, a
242 /// default-constructed object of the (template parameter) type `ALLOCATOR`
243 /// is used.
244 template <class INPUT_ITER>
245 stack(INPUT_ITER first, INPUT_ITER last);
246 template <class INPUT_ITER, class ALLOCATOR>
247 stack(INPUT_ITER first,
248 INPUT_ITER last,
249 const ALLOCATOR& allocator,
251 ALLOCATOR>::type * = 0);
252
253 /// Create a stack from the elements of the specifed `range`. Optionally
254 /// specify an `allocator` used to supply memory. If `allocator` is not
255 /// specified, a default-constructed object of the (template parameter) type `t_ALLOCATOR` is used.
256 ///
257 /// \note Note that `range` must meet the
258 /// requirements of an input range and the values from `range` must have a
259 /// type matching or convertible to (template parameter) `VALUE`.
260 template <class t_RANGE>
262 stack(from_range_t, BSLS_COMPILERFEATURES_FORWARD_REF(t_RANGE) range);
263 template <class t_RANGE, class t_ALLOCATOR>
265 stack(from_range_t ,
267 const t_ALLOCATOR& allocator,
269 t_ALLOCATOR>::type * = 0);
270
271 // MANIPULATORS
272
273 /// Assign to this object the value of the specified `rhs` object, and
274 /// return a reference providing modifiable access to this object.
275 stack& operator=(const stack& rhs);
276
277 /// Assign to this object the value of the specified `rhs` object, and
278 /// return a reference providing modifiable access to this object. The
279 /// contents of `rhs` are moved to this stack using the move-assignment
280 /// operator of `CONTAINER`. `rhs` is left in a valid but unspecified
281 /// state, and if an exception is thrown, `*this` is left in a valid but
282 /// unspecified state.
283 stack& operator=(BloombergLP::bslmf::MovableRef<stack> rhs)
285
286#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
287// {{{ BEGIN GENERATED CODE
288// Command line: sim_cpp11_features.pl bslstl_stack.h
289#ifndef BSLSTL_STACK_VARIADIC_LIMIT
290#define BSLSTL_STACK_VARIADIC_LIMIT 10
291#endif
292#ifndef BSLSTL_STACK_VARIADIC_LIMIT_A
293#define BSLSTL_STACK_VARIADIC_LIMIT_A BSLSTL_STACK_VARIADIC_LIMIT
294#endif
295#if BSLSTL_STACK_VARIADIC_LIMIT_A >= 0
297#endif // BSLSTL_STACK_VARIADIC_LIMIT_A >= 0
298
299#if BSLSTL_STACK_VARIADIC_LIMIT_A >= 1
300 template <class Args_01>
302#endif // BSLSTL_STACK_VARIADIC_LIMIT_A >= 1
303
304#if BSLSTL_STACK_VARIADIC_LIMIT_A >= 2
305 template <class Args_01,
306 class Args_02>
308 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) args_02);
309#endif // BSLSTL_STACK_VARIADIC_LIMIT_A >= 2
310
311#if BSLSTL_STACK_VARIADIC_LIMIT_A >= 3
312 template <class Args_01,
313 class Args_02,
314 class Args_03>
316 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) args_02,
317 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) args_03);
318#endif // BSLSTL_STACK_VARIADIC_LIMIT_A >= 3
319
320#if BSLSTL_STACK_VARIADIC_LIMIT_A >= 4
321 template <class Args_01,
322 class Args_02,
323 class Args_03,
324 class Args_04>
326 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) args_02,
327 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) args_03,
328 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) args_04);
329#endif // BSLSTL_STACK_VARIADIC_LIMIT_A >= 4
330
331#if BSLSTL_STACK_VARIADIC_LIMIT_A >= 5
332 template <class Args_01,
333 class Args_02,
334 class Args_03,
335 class Args_04,
336 class Args_05>
338 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) args_02,
339 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) args_03,
340 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) args_04,
341 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) args_05);
342#endif // BSLSTL_STACK_VARIADIC_LIMIT_A >= 5
343
344#if BSLSTL_STACK_VARIADIC_LIMIT_A >= 6
345 template <class Args_01,
346 class Args_02,
347 class Args_03,
348 class Args_04,
349 class Args_05,
350 class Args_06>
352 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) args_02,
353 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) args_03,
354 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) args_04,
355 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) args_05,
356 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) args_06);
357#endif // BSLSTL_STACK_VARIADIC_LIMIT_A >= 6
358
359#if BSLSTL_STACK_VARIADIC_LIMIT_A >= 7
360 template <class Args_01,
361 class Args_02,
362 class Args_03,
363 class Args_04,
364 class Args_05,
365 class Args_06,
366 class Args_07>
368 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) args_02,
369 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) args_03,
370 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) args_04,
371 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) args_05,
372 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) args_06,
373 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) args_07);
374#endif // BSLSTL_STACK_VARIADIC_LIMIT_A >= 7
375
376#if BSLSTL_STACK_VARIADIC_LIMIT_A >= 8
377 template <class Args_01,
378 class Args_02,
379 class Args_03,
380 class Args_04,
381 class Args_05,
382 class Args_06,
383 class Args_07,
384 class Args_08>
386 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) args_02,
387 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) args_03,
388 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) args_04,
389 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) args_05,
390 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) args_06,
391 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) args_07,
392 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) args_08);
393#endif // BSLSTL_STACK_VARIADIC_LIMIT_A >= 8
394
395#if BSLSTL_STACK_VARIADIC_LIMIT_A >= 9
396 template <class Args_01,
397 class Args_02,
398 class Args_03,
399 class Args_04,
400 class Args_05,
401 class Args_06,
402 class Args_07,
403 class Args_08,
404 class Args_09>
406 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) args_02,
407 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) args_03,
408 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) args_04,
409 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) args_05,
410 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) args_06,
411 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) args_07,
412 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) args_08,
413 BSLS_COMPILERFEATURES_FORWARD_REF(Args_09) args_09);
414#endif // BSLSTL_STACK_VARIADIC_LIMIT_A >= 9
415
416#if BSLSTL_STACK_VARIADIC_LIMIT_A >= 10
417 template <class Args_01,
418 class Args_02,
419 class Args_03,
420 class Args_04,
421 class Args_05,
422 class Args_06,
423 class Args_07,
424 class Args_08,
425 class Args_09,
426 class Args_10>
428 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) args_02,
429 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) args_03,
430 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) args_04,
431 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) args_05,
432 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) args_06,
433 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) args_07,
434 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) args_08,
435 BSLS_COMPILERFEATURES_FORWARD_REF(Args_09) args_09,
436 BSLS_COMPILERFEATURES_FORWARD_REF(Args_10) args_10);
437#endif // BSLSTL_STACK_VARIADIC_LIMIT_A >= 10
438
439#else
440// The generated code below is a workaround for the absence of perfect
441// forwarding in some compilers.
442 template <class... Args>
444
445// }}} END GENERATED CODE
446#endif
447
448 /// Remove the top element from this stack.
449 ///
450 /// \pre The behavior is undefined if this stack is empty.
451 void pop();
452
453 /// Push the specified `value` onto the top of this stack.
454 void push(const value_type& value);
455
456 /// Push onto this stack a `value_type` object having the value of the
457 /// specified `value` (on entry) by moving the contents of `value` to
458 /// the new object on this stack. `value` is left in a valid but
459 /// unspecified state.
460 void push(BloombergLP::bslmf::MovableRef<value_type> value);
461
462 /// Push onto this stack the elements of the specified `range`.
463 ///
464 /// \note Note that `range` must meet the requirements of an input range and the values
465 /// from `range` must have a type matching or convertible to (template
466 /// parameter) `VALUE`.
467 template <class t_RANGE>
470
471 /// Exchange the value of this stack with the value of the specified
472 /// `other` stack.
474 bsl::is_nothrow_swappable<CONTAINER>::value);
475
476 /// Return a reference to the element at the top of this stack.
477 ///
478 /// \pre The behavior is undefined if this stack is empty.
479 reference top();
480
481 // ACCESSORS
482
483 /// Return `true` if this stack contains no elements and `false`
484 /// otherwise.
485 bool empty() const;
486
487 /// Return the number of elements contained in this stack.
488 size_type size() const;
489
490 /// Return a reference providing non-modifiable access to the element at the top of this stack.
491 ///
492 /// \pre The behavior is undefined if the stack is
493 /// empty.
494 const_reference top() const;
495};
496
497#ifdef BSLS_COMPILERFEATURES_SUPPORT_CTAD
498// CLASS TEMPLATE DEDUCTION GUIDES
499
500/// Deduce the template parameters `VALUE` and `CONTAINER` from the
501/// parameters supplied to the constructor of `stack`. This deduction guide
502/// does not participate if the parameter meets the requirements for a
503/// standard allocator.
504template<class CONTAINER,
505 class = bsl::enable_if_t<!bsl::IsStdAllocator_v<CONTAINER>>
506 >
507stack(CONTAINER) -> stack<typename CONTAINER::value_type, CONTAINER>;
508
509/// Deduce the template parameters `VALUE` and `CONTAINER` from the
510/// parameters supplied to the constructor of `stack`. This deduction
511/// guide does not participate unless the supplied allocator is convertible
512/// to the underlying container's `allocator_type`.
513template<
514 class CONTAINER,
515 class ALLOCATOR,
516 class = bsl::enable_if_t<bsl::uses_allocator_v<CONTAINER, ALLOCATOR>>
517 >
518stack(CONTAINER, ALLOCATOR) -> stack<typename CONTAINER::value_type, CONTAINER>;
519
520/// Deduce the template parameter `VALUE` from the parameters supplied to the
521/// constructor of `stack`.
522template <class INPUT_ITER,
523 class TYPE = BloombergLP::bslstl::IteratorUtil::
524 IterVal_t<INPUT_ITER>>
525stack(INPUT_ITER, INPUT_ITER) -> stack<TYPE>;
526
527/// Deduce the template parameters `VALUE` and `CONTAINER` from the parameters
528/// supplied to the constructor of `stack`. This deduction guide does not
529/// participate unless the `ALLOCATOR` parameter meets the requirements for a
530/// standard allocator.
531template <class INPUT_ITER,
532 class ALLOCATOR,
533 class TYPE = BloombergLP::bslstl::IteratorUtil::
534 IterVal_t<INPUT_ITER>,
535 class = enable_if_t<IsStdAllocator_v<ALLOCATOR>>>
536stack(INPUT_ITER, INPUT_ITER, ALLOCATOR)-> stack<TYPE, deque<TYPE, ALLOCATOR>>;
537
538#if defined(BSLS_LIBRARYFEATURES_HAS_CPP20_RANGES)
539/// Deduce the template parameter `VALUE` from the parameters supplied to the
540/// constructor of `stack`.
541template <ranges::input_range t_RANGE>
542stack(from_range_t, t_RANGE&&) -> stack<ranges::range_value_t<t_RANGE>>;
543
544/// Deduce the template parameters `VALUE` and `ALLOCATOR` from the parameters
545/// supplied to the constructor of `stack`. This deduction guide does not
546/// participate unless the `t_ALLOCATOR` parameter meets the requirements for a
547/// standard allocator.
548template <ranges::input_range t_RANGE,
549 class t_ALLOCATOR,
550 class t_TYPE = ranges::range_value_t<t_RANGE>>
551requires IsStdAllocator_v<t_ALLOCATOR>
552stack(from_range_t, t_RANGE&&, t_ALLOCATOR)
553-> stack<t_TYPE, deque<t_TYPE, t_ALLOCATOR>>;
554#endif
555#endif
556
557// FREE OPERATORS
558
559/// Return `true` if the specified `lhs` and `rhs` objects have the same
560/// value, and `false` otherwise. Two `stack` objects `lhs` and `rhs` have
561/// the same value if they have the same number of elements, and each
562/// element in the ordered sequence of elements of `lhs` has the same value
563/// as the corresponding element in the ordered sequence of elements of
564/// `rhs`. This method requires that the (template parameter) type `VALUE`
565/// be `equality-comparable` (see {Requirements on `VALUE`}).
566template <class VALUE, class CONTAINER>
567bool operator==(const stack<VALUE, CONTAINER>& lhs,
568 const stack<VALUE, CONTAINER>& rhs);
569
570/// Return `true` if the specified `lhs` and `rhs` objects do not have the
571/// same value, and `false` otherwise. Two `stack` objects `lhs` and `rhs`
572/// do not have the same value if they do not have the same number of
573/// elements, or some element in the ordered sequence of elements of `lhs`
574/// does not have the same value as the corresponding element in the ordered
575/// sequence of elements of `rhs`. This method requires that the (template
576/// parameter) type `VALUE` be `equality-comparable` (see {Requirements on
577/// `VALUE`}).
578template <class VALUE, class CONTAINER>
579bool operator!=(const stack<VALUE, CONTAINER>& lhs,
580 const stack<VALUE, CONTAINER>& rhs);
581
582/// Return `true` if the value of the specified `lhs` stack is
583/// lexicographically less than that of the specified `rhs` stack, and
584/// `false` otherwise. Given iterators `i` and `j` over the respective
585/// sequences `[lhs.begin() .. lhs.end())` and `[rhs.begin() .. rhs.end())`,
586/// the value of stack `lhs` is lexicographically less than that of stack
587/// `rhs` if `true == *i < *j` for the first pair of corresponding iterator
588/// positions where `*i < *j` and `*j < *i` are not both `false`. If no
589/// such corresponding iterator position exists, the value of `lhs` is
590/// lexicographically less than that of `rhs` if `lhs.size() < rhs.size()`.
591/// This method requires that `operator<`, inducing a total order, be
592/// defined for `value_type`.
593template <class VALUE, class CONTAINER>
594bool operator< (const stack<VALUE, CONTAINER>& lhs,
595 const stack<VALUE, CONTAINER>& rhs);
596
597/// Return `true` if the value of the specified `lhs` stack is
598/// lexicographically greater than that of the specified `rhs` stack, and
599/// `false` otherwise. The value of stack `lhs` is lexicographically
600/// greater than that of stack `rhs` if `rhs` is lexicographically less than
601/// `lhs` (see `operator<`). This method requires that `operator<`, inducing a total order, be defined for `value_type`.
602///
603/// \note Note that this
604/// operator returns `rhs < lhs`.
605template <class VALUE, class CONTAINER>
606bool operator> (const stack<VALUE, CONTAINER>& lhs,
607 const stack<VALUE, CONTAINER>& rhs);
608
609/// Return `true` if the value of the specified `lhs` stack is
610/// lexicographically less than or equal to that of the specified `rhs`
611/// stack, and `false` otherwise. The value of stack `lhs` is
612/// lexicographically less than or equal to that of stack `rhs` if `rhs` is
613/// not lexicographically less than `lhs` (see `operator<`). This method
614/// requires that `operator<`, inducing a total order, be defined for `value_type`.
615///
616/// \note Note that this operator returns `!(rhs < lhs)`.
617template <class VALUE, class CONTAINER>
618bool operator<=(const stack<VALUE, CONTAINER>& lhs,
619 const stack<VALUE, CONTAINER>& rhs);
620
621/// Return `true` if the value of the specified `lhs` stack is
622/// lexicographically greater than or equal to that of the specified `rhs`
623/// stack, and `false` otherwise. The value of stack `lhs` is
624/// lexicographically greater than or equal to that of stack `rhs` if `lhs`
625/// is not lexicographically less than `rhs` (see `operator<`). This method
626/// requires that `operator<`, inducing a total order, be defined for `value_type`.
627///
628/// \note Note that this operator returns `!(lhs < rhs)`.
629template <class VALUE, class CONTAINER>
630bool operator>=(const stack<VALUE, CONTAINER>& lhs,
631 const stack<VALUE, CONTAINER>& rhs);
632
633// FREE FUNCTIONS
634
635/// Swap the value of the specified `lhs` stack with the value of the
636/// specified `rhs` stack.
637template <class VALUE, class CONTAINER>
638void swap(stack<VALUE, CONTAINER>& lhs,
639 stack<VALUE, CONTAINER>& rhs)
641
642//=============================================================================
643// TEMPLATE AND INLINE FUNCTION DEFINITIONS
644//=============================================================================
645
646 // -----------
647 // class stack
648 // -----------
649
650// CREATORS
651template <class VALUE, class CONTAINER>
652inline
654: c()
655{
656}
657
658template <class VALUE, class CONTAINER>
659inline
660stack<VALUE, CONTAINER>::stack(const CONTAINER& container)
661: c(container)
662{
663}
664
665template <class VALUE, class CONTAINER>
666inline
667stack<VALUE, CONTAINER>::stack(BloombergLP::bslmf::MovableRef<stack> original)
668: c(MoveUtil::move(MoveUtil::access(original).c))
669{
670}
671
672template <class VALUE, class CONTAINER>
673template <class ALLOCATOR>
674inline
675stack<VALUE, CONTAINER>::stack(const ALLOCATOR& basicAllocator,
677 ALLOCATOR>::type *)
678: c(basicAllocator)
679{
680}
681
682template <class VALUE, class CONTAINER>
683template <class ALLOCATOR>
684inline
685stack<VALUE, CONTAINER>::stack(
686 const CONTAINER& container,
687 const ALLOCATOR& basicAllocator,
689 ALLOCATOR>::type *)
690: c(container, basicAllocator)
691{
692}
693
694template <class VALUE, class CONTAINER>
695inline
696stack<VALUE, CONTAINER>::stack(const stack& original)
697: c(original.c)
698{
699}
700
701template <class VALUE, class CONTAINER>
702template <class ALLOCATOR>
703inline
704stack<VALUE, CONTAINER>::stack(
705 const stack& original,
706 const ALLOCATOR& basicAllocator,
708 ALLOCATOR>::type *)
709: c(original.c, basicAllocator)
710{
711}
712
713template <class VALUE, class CONTAINER>
714inline
715stack<VALUE, CONTAINER>::stack(BloombergLP::bslmf::MovableRef<CONTAINER>
716 container)
717: c(MoveUtil::move(container))
718{
719}
720
721template <class VALUE, class CONTAINER>
722template <class ALLOCATOR>
723inline
724stack<VALUE, CONTAINER>::stack(
725 BloombergLP::bslmf::MovableRef<CONTAINER> container,
726 const ALLOCATOR& basicAllocator,
728 ALLOCATOR>::type *)
729: c(MoveUtil::move(container), basicAllocator)
730{
731}
732
733template <class VALUE, class CONTAINER>
734template <class ALLOCATOR>
735inline
736stack<VALUE, CONTAINER>::stack(
737 BloombergLP::bslmf::MovableRef<stack> original,
738 const ALLOCATOR& basicAllocator,
740 ALLOCATOR>::type *)
741: c(MoveUtil::move(MoveUtil::access(original).c), basicAllocator)
742{
743}
744
745template <class VALUE, class CONTAINER>
746template <class INPUT_ITER>
747inline
748stack<VALUE, CONTAINER>::stack(INPUT_ITER first, INPUT_ITER last)
749: c(first, last)
750{
751}
752
753template <class VALUE, class CONTAINER>
754template <class INPUT_ITER, class ALLOCATOR>
755inline
756stack<VALUE, CONTAINER>::stack(
757 INPUT_ITER first,
758 INPUT_ITER last,
759 const ALLOCATOR& allocator,
761 ALLOCATOR>::type *)
762: c(first, last, allocator)
763{
764}
765
766template <class VALUE, class CONTAINER>
767template <class t_RANGE>
769inline
770stack<VALUE, CONTAINER>::stack(
771 from_range_t ,
773#ifdef BSLS_LIBRARYFEATURES_HAS_CPP23_RANGES_TO_CONTAINER
774: c(ranges::to<CONTAINER>(std::forward<t_RANGE>(range)))
775#else
777#endif
778{
779}
780
781template <class VALUE, class CONTAINER>
782template <class t_RANGE, class t_ALLOCATOR>
784inline
785stack<VALUE, CONTAINER>::stack(
786 from_range_t ,
788 const t_ALLOCATOR& allocator,
789 typename enable_if<
791 t_ALLOCATOR>::type *)
792#ifdef BSLS_LIBRARYFEATURES_HAS_CPP23_RANGES_TO_CONTAINER
793: c(ranges::to<CONTAINER>(std::forward<t_RANGE>(range), allocator))
794#else
795: c(bsl::from_range, BSLS_COMPILERFEATURES_FORWARD(t_RANGE, range), allocator)
796#endif
797{
798}
799
800// PRIVATE MANIPULATORS
801template <class VALUE, class CONTAINER>
802template <class INPUT_ITER, class SENTINEL>
803inline
804void stack<VALUE, CONTAINER>::privatePushRange(INPUT_ITER first,
805 SENTINEL last)
806{
807 while (first != last) {
808 push(*first);
809 ++first;
810 }
811}
812
813// MANIPULATORS
814template <class VALUE, class CONTAINER>
815inline
816stack<VALUE, CONTAINER>& stack<VALUE, CONTAINER>::operator=(const stack& rhs)
817{
818 c = rhs.c;
819
820 return *this;
821}
822
823template <class VALUE, class CONTAINER>
824inline
825stack<VALUE, CONTAINER>& stack<VALUE, CONTAINER>::operator=(
826 BloombergLP::bslmf::MovableRef<stack> rhs)
828{
829 c = MoveUtil::move(MoveUtil::access(rhs).c);
830 return *this;
831}
832
833#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
834// {{{ BEGIN GENERATED CODE
835// Command line: sim_cpp11_features.pl bslstl_stack.h
836#ifndef BSLSTL_STACK_VARIADIC_LIMIT
837#define BSLSTL_STACK_VARIADIC_LIMIT 10
838#endif
839#ifndef BSLSTL_STACK_VARIADIC_LIMIT_B
840#define BSLSTL_STACK_VARIADIC_LIMIT_B BSLSTL_STACK_VARIADIC_LIMIT
841#endif
842#if BSLSTL_STACK_VARIADIC_LIMIT_B >= 0
843template <class VALUE, class CONTAINER>
844inline
845typename stack<VALUE, CONTAINER>::reference
846stack<VALUE, CONTAINER>::emplace(
847 )
848{
849 c.emplace_back();
850 return top();
851}
852#endif // BSLSTL_STACK_VARIADIC_LIMIT_B >= 0
853
854#if BSLSTL_STACK_VARIADIC_LIMIT_B >= 1
855template <class VALUE, class CONTAINER>
856template <class Args_01>
857inline
858typename stack<VALUE, CONTAINER>::reference
859stack<VALUE, CONTAINER>::emplace(
860 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) args_01)
861{
862 c.emplace_back(BSLS_COMPILERFEATURES_FORWARD(Args_01,args_01));
863 return top();
864}
865#endif // BSLSTL_STACK_VARIADIC_LIMIT_B >= 1
866
867#if BSLSTL_STACK_VARIADIC_LIMIT_B >= 2
868template <class VALUE, class CONTAINER>
869template <class Args_01,
870 class Args_02>
871inline
872typename stack<VALUE, CONTAINER>::reference
873stack<VALUE, CONTAINER>::emplace(
874 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) args_01,
875 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) args_02)
876{
877 c.emplace_back(BSLS_COMPILERFEATURES_FORWARD(Args_01,args_01),
878 BSLS_COMPILERFEATURES_FORWARD(Args_02,args_02));
879 return top();
880}
881#endif // BSLSTL_STACK_VARIADIC_LIMIT_B >= 2
882
883#if BSLSTL_STACK_VARIADIC_LIMIT_B >= 3
884template <class VALUE, class CONTAINER>
885template <class Args_01,
886 class Args_02,
887 class Args_03>
888inline
889typename stack<VALUE, CONTAINER>::reference
890stack<VALUE, CONTAINER>::emplace(
891 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) args_01,
892 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) args_02,
893 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) args_03)
894{
895 c.emplace_back(BSLS_COMPILERFEATURES_FORWARD(Args_01,args_01),
896 BSLS_COMPILERFEATURES_FORWARD(Args_02,args_02),
897 BSLS_COMPILERFEATURES_FORWARD(Args_03,args_03));
898 return top();
899}
900#endif // BSLSTL_STACK_VARIADIC_LIMIT_B >= 3
901
902#if BSLSTL_STACK_VARIADIC_LIMIT_B >= 4
903template <class VALUE, class CONTAINER>
904template <class Args_01,
905 class Args_02,
906 class Args_03,
907 class Args_04>
908inline
909typename stack<VALUE, CONTAINER>::reference
910stack<VALUE, CONTAINER>::emplace(
911 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) args_01,
912 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) args_02,
913 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) args_03,
914 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) args_04)
915{
916 c.emplace_back(BSLS_COMPILERFEATURES_FORWARD(Args_01,args_01),
917 BSLS_COMPILERFEATURES_FORWARD(Args_02,args_02),
918 BSLS_COMPILERFEATURES_FORWARD(Args_03,args_03),
919 BSLS_COMPILERFEATURES_FORWARD(Args_04,args_04));
920 return top();
921}
922#endif // BSLSTL_STACK_VARIADIC_LIMIT_B >= 4
923
924#if BSLSTL_STACK_VARIADIC_LIMIT_B >= 5
925template <class VALUE, class CONTAINER>
926template <class Args_01,
927 class Args_02,
928 class Args_03,
929 class Args_04,
930 class Args_05>
931inline
932typename stack<VALUE, CONTAINER>::reference
933stack<VALUE, CONTAINER>::emplace(
934 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) args_01,
935 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) args_02,
936 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) args_03,
937 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) args_04,
938 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) args_05)
939{
940 c.emplace_back(BSLS_COMPILERFEATURES_FORWARD(Args_01,args_01),
941 BSLS_COMPILERFEATURES_FORWARD(Args_02,args_02),
942 BSLS_COMPILERFEATURES_FORWARD(Args_03,args_03),
943 BSLS_COMPILERFEATURES_FORWARD(Args_04,args_04),
944 BSLS_COMPILERFEATURES_FORWARD(Args_05,args_05));
945 return top();
946}
947#endif // BSLSTL_STACK_VARIADIC_LIMIT_B >= 5
948
949#if BSLSTL_STACK_VARIADIC_LIMIT_B >= 6
950template <class VALUE, class CONTAINER>
951template <class Args_01,
952 class Args_02,
953 class Args_03,
954 class Args_04,
955 class Args_05,
956 class Args_06>
957inline
958typename stack<VALUE, CONTAINER>::reference
959stack<VALUE, CONTAINER>::emplace(
960 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) args_01,
961 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) args_02,
962 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) args_03,
963 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) args_04,
964 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) args_05,
965 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) args_06)
966{
967 c.emplace_back(BSLS_COMPILERFEATURES_FORWARD(Args_01,args_01),
968 BSLS_COMPILERFEATURES_FORWARD(Args_02,args_02),
969 BSLS_COMPILERFEATURES_FORWARD(Args_03,args_03),
970 BSLS_COMPILERFEATURES_FORWARD(Args_04,args_04),
971 BSLS_COMPILERFEATURES_FORWARD(Args_05,args_05),
972 BSLS_COMPILERFEATURES_FORWARD(Args_06,args_06));
973 return top();
974}
975#endif // BSLSTL_STACK_VARIADIC_LIMIT_B >= 6
976
977#if BSLSTL_STACK_VARIADIC_LIMIT_B >= 7
978template <class VALUE, class CONTAINER>
979template <class Args_01,
980 class Args_02,
981 class Args_03,
982 class Args_04,
983 class Args_05,
984 class Args_06,
985 class Args_07>
986inline
987typename stack<VALUE, CONTAINER>::reference
988stack<VALUE, CONTAINER>::emplace(
989 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) args_01,
990 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) args_02,
991 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) args_03,
992 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) args_04,
993 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) args_05,
994 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) args_06,
995 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) args_07)
996{
997 c.emplace_back(BSLS_COMPILERFEATURES_FORWARD(Args_01,args_01),
998 BSLS_COMPILERFEATURES_FORWARD(Args_02,args_02),
999 BSLS_COMPILERFEATURES_FORWARD(Args_03,args_03),
1000 BSLS_COMPILERFEATURES_FORWARD(Args_04,args_04),
1001 BSLS_COMPILERFEATURES_FORWARD(Args_05,args_05),
1002 BSLS_COMPILERFEATURES_FORWARD(Args_06,args_06),
1003 BSLS_COMPILERFEATURES_FORWARD(Args_07,args_07));
1004 return top();
1005}
1006#endif // BSLSTL_STACK_VARIADIC_LIMIT_B >= 7
1007
1008#if BSLSTL_STACK_VARIADIC_LIMIT_B >= 8
1009template <class VALUE, class CONTAINER>
1010template <class Args_01,
1011 class Args_02,
1012 class Args_03,
1013 class Args_04,
1014 class Args_05,
1015 class Args_06,
1016 class Args_07,
1017 class Args_08>
1018inline
1019typename stack<VALUE, CONTAINER>::reference
1020stack<VALUE, CONTAINER>::emplace(
1021 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) args_01,
1022 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) args_02,
1023 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) args_03,
1024 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) args_04,
1025 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) args_05,
1026 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) args_06,
1027 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) args_07,
1028 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) args_08)
1029{
1030 c.emplace_back(BSLS_COMPILERFEATURES_FORWARD(Args_01,args_01),
1031 BSLS_COMPILERFEATURES_FORWARD(Args_02,args_02),
1032 BSLS_COMPILERFEATURES_FORWARD(Args_03,args_03),
1033 BSLS_COMPILERFEATURES_FORWARD(Args_04,args_04),
1034 BSLS_COMPILERFEATURES_FORWARD(Args_05,args_05),
1035 BSLS_COMPILERFEATURES_FORWARD(Args_06,args_06),
1036 BSLS_COMPILERFEATURES_FORWARD(Args_07,args_07),
1037 BSLS_COMPILERFEATURES_FORWARD(Args_08,args_08));
1038 return top();
1039}
1040#endif // BSLSTL_STACK_VARIADIC_LIMIT_B >= 8
1041
1042#if BSLSTL_STACK_VARIADIC_LIMIT_B >= 9
1043template <class VALUE, class CONTAINER>
1044template <class Args_01,
1045 class Args_02,
1046 class Args_03,
1047 class Args_04,
1048 class Args_05,
1049 class Args_06,
1050 class Args_07,
1051 class Args_08,
1052 class Args_09>
1053inline
1054typename stack<VALUE, CONTAINER>::reference
1055stack<VALUE, CONTAINER>::emplace(
1056 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) args_01,
1057 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) args_02,
1058 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) args_03,
1059 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) args_04,
1060 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) args_05,
1061 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) args_06,
1062 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) args_07,
1063 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) args_08,
1064 BSLS_COMPILERFEATURES_FORWARD_REF(Args_09) args_09)
1065{
1066 c.emplace_back(BSLS_COMPILERFEATURES_FORWARD(Args_01,args_01),
1067 BSLS_COMPILERFEATURES_FORWARD(Args_02,args_02),
1068 BSLS_COMPILERFEATURES_FORWARD(Args_03,args_03),
1069 BSLS_COMPILERFEATURES_FORWARD(Args_04,args_04),
1070 BSLS_COMPILERFEATURES_FORWARD(Args_05,args_05),
1071 BSLS_COMPILERFEATURES_FORWARD(Args_06,args_06),
1072 BSLS_COMPILERFEATURES_FORWARD(Args_07,args_07),
1073 BSLS_COMPILERFEATURES_FORWARD(Args_08,args_08),
1074 BSLS_COMPILERFEATURES_FORWARD(Args_09,args_09));
1075 return top();
1076}
1077#endif // BSLSTL_STACK_VARIADIC_LIMIT_B >= 9
1078
1079#if BSLSTL_STACK_VARIADIC_LIMIT_B >= 10
1080template <class VALUE, class CONTAINER>
1081template <class Args_01,
1082 class Args_02,
1083 class Args_03,
1084 class Args_04,
1085 class Args_05,
1086 class Args_06,
1087 class Args_07,
1088 class Args_08,
1089 class Args_09,
1090 class Args_10>
1091inline
1092typename stack<VALUE, CONTAINER>::reference
1093stack<VALUE, CONTAINER>::emplace(
1094 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) args_01,
1095 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) args_02,
1096 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) args_03,
1097 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) args_04,
1098 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) args_05,
1099 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) args_06,
1100 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) args_07,
1101 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) args_08,
1102 BSLS_COMPILERFEATURES_FORWARD_REF(Args_09) args_09,
1103 BSLS_COMPILERFEATURES_FORWARD_REF(Args_10) args_10)
1104{
1105 c.emplace_back(BSLS_COMPILERFEATURES_FORWARD(Args_01,args_01),
1106 BSLS_COMPILERFEATURES_FORWARD(Args_02,args_02),
1107 BSLS_COMPILERFEATURES_FORWARD(Args_03,args_03),
1108 BSLS_COMPILERFEATURES_FORWARD(Args_04,args_04),
1109 BSLS_COMPILERFEATURES_FORWARD(Args_05,args_05),
1110 BSLS_COMPILERFEATURES_FORWARD(Args_06,args_06),
1111 BSLS_COMPILERFEATURES_FORWARD(Args_07,args_07),
1112 BSLS_COMPILERFEATURES_FORWARD(Args_08,args_08),
1113 BSLS_COMPILERFEATURES_FORWARD(Args_09,args_09),
1114 BSLS_COMPILERFEATURES_FORWARD(Args_10,args_10));
1115 return top();
1116}
1117#endif // BSLSTL_STACK_VARIADIC_LIMIT_B >= 10
1118
1119#else
1120// The generated code below is a workaround for the absence of perfect
1121// forwarding in some compilers.
1122template <class VALUE, class CONTAINER>
1123template <class... Args>
1124inline
1125typename stack<VALUE, CONTAINER>::reference
1126stack<VALUE, CONTAINER>::emplace(
1128{
1129 c.emplace_back(BSLS_COMPILERFEATURES_FORWARD(Args,args)...);
1130 return top();
1131}
1132// }}} END GENERATED CODE
1133#endif
1134
1135template <class VALUE, class CONTAINER>
1136inline
1137void stack<VALUE, CONTAINER>::pop()
1138{
1140
1141 c.pop_back();
1142}
1143
1144template <class VALUE, class CONTAINER>
1145inline
1146void stack<VALUE, CONTAINER>::push(const value_type& value)
1147{
1148 c.push_back(value);
1149}
1150
1151template <class VALUE, class CONTAINER>
1152inline
1153void stack<VALUE, CONTAINER>::push(BloombergLP::bslmf::MovableRef<value_type>
1154 value)
1155{
1156 c.push_back(MoveUtil::move(value));
1157}
1158
1159template <class VALUE, class CONTAINER>
1160template <class t_RANGE>
1162void stack<VALUE, CONTAINER>::push_range(
1163 BSLS_COMPILERFEATURES_FORWARD_REF(t_RANGE) range)
1164{
1165#if defined(BSLS_LIBRARYFEATURES_HAS_CPP20_RANGES)
1166 if constexpr (requires{ c.append_range(std::forward<t_RANGE>(range)); }) {
1167 c.append_range(std::forward<t_RANGE>(range));
1168 }
1169 else {
1170 ranges::copy(range, back_inserter(c));
1171 }
1172#else
1173 privatePushRange(bsl::begin(range), bsl::end(range));
1174#endif
1175}
1176
1177template <class VALUE, class CONTAINER>
1178inline
1179void stack<VALUE, CONTAINER>::swap(stack& other)
1181 bsl::is_nothrow_swappable<CONTAINER>::value)
1182{
1183 BloombergLP::bslalg::SwapUtil::swap(&c, &other.c);
1184}
1185
1186template <class VALUE, class CONTAINER>
1187inline
1188typename CONTAINER::reference stack<VALUE, CONTAINER>::top()
1189{
1191
1192 return c.back();
1193}
1194
1195// ACCESSORS
1196template <class VALUE, class CONTAINER>
1197inline
1198bool stack<VALUE, CONTAINER>::empty() const
1199{
1200 return 0 == c.size();
1201}
1202
1203template <class VALUE, class CONTAINER>
1204inline
1205typename CONTAINER::size_type stack<VALUE, CONTAINER>::size() const
1206{
1207 return c.size();
1208}
1209
1210template <class VALUE, class CONTAINER>
1211inline
1212typename CONTAINER::const_reference stack<VALUE, CONTAINER>::top() const
1213{
1214 return c.back();
1215}
1216
1217// FREE OPERATORS
1218template <class VALUE, class CONTAINER>
1219inline
1220bool operator==(const stack<VALUE, CONTAINER>& lhs,
1221 const stack<VALUE, CONTAINER>& rhs)
1222{
1223 return lhs.c == rhs.c;
1224}
1225
1226template <class VALUE, class CONTAINER>
1227inline
1228bool operator!=(const stack<VALUE, CONTAINER>& lhs,
1229 const stack<VALUE, CONTAINER>& rhs)
1230{
1231 return lhs.c != rhs.c;
1232}
1233
1234template <class VALUE, class CONTAINER>
1235inline
1236bool operator< (const stack<VALUE, CONTAINER>& lhs,
1237 const stack<VALUE, CONTAINER>& rhs)
1238{
1239 return lhs.c < rhs.c;
1240}
1241
1242template <class VALUE, class CONTAINER>
1243inline
1244bool operator> (const stack<VALUE, CONTAINER>& lhs,
1245 const stack<VALUE, CONTAINER>& rhs)
1246{
1247 return lhs.c > rhs.c;
1248}
1249
1250template <class VALUE, class CONTAINER>
1251inline
1252bool operator<=(const stack<VALUE, CONTAINER>& lhs,
1253 const stack<VALUE, CONTAINER>& rhs)
1254{
1255 return lhs.c <= rhs.c;
1256}
1257
1258template <class VALUE, class CONTAINER>
1259inline
1260bool operator>=(const stack<VALUE, CONTAINER>& lhs,
1261 const stack<VALUE, CONTAINER>& rhs)
1262{
1263 return lhs.c >= rhs.c;
1264}
1265
1266#if defined BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON \
1267 && defined BSLS_LIBRARYFEATURES_HAS_CPP20_CONCEPTS
1268template <class VALUE, three_way_comparable CONTAINER>
1269inline compare_three_way_result_t<CONTAINER>
1270operator<=>(const stack<VALUE, CONTAINER>& lhs,
1271 const stack<VALUE, CONTAINER>& rhs)
1272{
1273 return lhs.c <=> rhs.c;
1274}
1275#endif
1276
1277// FREE FUNCTIONS
1278template <class VALUE, class CONTAINER>
1279inline
1280void swap(stack<VALUE, CONTAINER>& lhs,
1281 stack<VALUE, CONTAINER>& rhs)
1283{
1284 lhs.swap(rhs);
1285}
1286
1287} // close namespace bsl
1288
1289#else // if ! defined(DEFINED_BSLSTL_STACK_H)
1290# error Not valid except when included from bslstl_stack.h
1291#endif // ! defined(COMPILING_BSLSTL_STACK_H)
1292
1293#endif // ! defined(INCLUDED_BSLSTL_STACK_CPP03)
1294
1295// ----------------------------------------------------------------------------
1296// Copyright 2016 Bloomberg Finance L.P.
1297//
1298// Licensed under the Apache License, Version 2.0 (the "License");
1299// you may not use this file except in compliance with the License.
1300// You may obtain a copy of the License at
1301//
1302// http://www.apache.org/licenses/LICENSE-2.0
1303//
1304// Unless required by applicable law or agreed to in writing, software
1305// distributed under the License is distributed on an "AS IS" BASIS,
1306// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1307// See the License for the specific language governing permissions and
1308// limitations under the License.
1309// ----------------------------- END-OF-FILE ----------------------------------
1310
1311/** @} */
1312/** @} */
1313/** @} */
#define BSLMF_NESTED_TRAIT_DECLARATION_IF(t_TYPE, t_TRAIT, t_COND)
Definition bslmf_nestedtraitdeclaration.h:243
CONTAINER::reference reference
Definition bslstl_stack.h:436
CONTAINER::size_type size_type
Definition bslstl_stack.h:438
friend bool operator>(const stack< VAL, CONT > &, const stack< VAL, CONT > &)
stack()
Definition bslstl_stack.h:829
friend bool operator<(const stack< VAL, CONT > &, const stack< VAL, CONT > &)
CONTAINER container_type
Definition bslstl_stack.h:439
friend bool operator!=(const stack< VAL, CONT > &, const stack< VAL, CONT > &)
void push_range(BSLS_COMPILERFEATURES_FORWARD_REF(t_RANGE) range)
Definition bslstl_stack.h:1048
friend bool operator>=(const stack< VAL, CONT > &, const stack< VAL, CONT > &)
bool empty() const
Definition bslstl_stack.h:1084
friend bool operator==(const stack< VAL, CONT > &, const stack< VAL, CONT > &)
void pop()
Definition bslstl_stack.h:1023
void push(const value_type &value)
Push the specified value onto the top of this stack.
Definition bslstl_stack.h:1032
void swap(stack &other) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(bsl reference top()
Definition bslstl_stack.h:655
stack & operator=(const stack &rhs)
Definition bslstl_stack.h:992
friend bool operator<=(const stack< VAL, CONT > &, const stack< VAL, CONT > &)
size_type size() const
Return the number of elements contained in this stack.
Definition bslstl_stack.h:1091
CONTAINER::value_type value_type
Definition bslstl_stack.h:435
CONTAINER::const_reference const_reference
Definition bslstl_stack.h:437
container_type c
Definition bslstl_stack.h:444
reference emplace(Args &&... args)
Definition bslstl_stack.h:1014
#define BSLMF_ASSERT(expr)
Definition bslmf_assert.h:231
static const t_TYPE value
Definition bslmf_integralconstant.h:267
#define BSLS_ASSERT_SAFE(X)
Definition bsls_assert.h:1917
#define BSLS_COMPILERFEATURES_FORWARD_REF(T)
Definition bsls_compilerfeatures.h:2343
#define BSLS_COMPILERFEATURES_FORWARD(T, V)
Definition bsls_compilerfeatures.h:2349
#define BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(...)
Definition bsls_keyword.h:676
#define BSLSTL_STACK_REQUIRES_CONTAINER_COMPATIBLE_RANGE(R, T)
Definition bslstl_stack.h:376
bool operator!=(const FileCleanerConfiguration &lhs, const FileCleanerConfiguration &rhs)
bool operator==(const FileCleanerConfiguration &lhs, const FileCleanerConfiguration &rhs)
void swap(OptionValue &a, OptionValue &b)
bool operator>=(const Guid &lhs, const Guid &rhs)
bool operator<=(const Guid &lhs, const Guid &rhs)
Definition bdlat_valuetypefunctions.h:939
ALLOCATOR const STRING_VIEW_LIKE_TYPE & rhs
Definition bslstl_string.h:3918
T::iterator begin(T &container)
Definition bslstl_iterator.h:1593
const from_range_t from_range
ALLOCATOR & lhs
Definition bslstl_string.h:3917
T::iterator end(T &container)
Definition bslstl_iterator.h:1621
BSLS_KEYWORD_CONSTEXPR bool empty(const CONTAINER &container)
Definition bslstl_iterator.h:1377
Definition bslmf_usesallocator.h:165