61#if __cplusplus >= 201103L
62# include <bits/uses_allocator.h>
64#if __glibcxx_containers_ranges
69namespace std _GLIBCXX_VISIBILITY(default)
71_GLIBCXX_BEGIN_NAMESPACE_VERSION
102 template<
typename _Tp,
typename _Sequence = deque<_Tp> >
105#ifdef _GLIBCXX_CONCEPT_CHECKS
107 typedef typename _Sequence::value_type _Sequence_value_type;
108# if __cplusplus < 201103L
109 __glibcxx_class_requires(_Tp, _SGIAssignableConcept)
110 __glibcxx_class_requires(_Sequence, _BackInsertionSequenceConcept)
112 __glibcxx_class_requires2(_Tp, _Sequence_value_type, _SameTypeConcept)
115 template<
typename _Tp1,
typename _Seq1>
119 template<
typename _Tp1,
typename _Seq1>
123#if __cpp_lib_three_way_comparison
124 template<
typename _Tp1, three_way_comparable _Seq1>
129#if __cplusplus >= 201103L
130 template<
typename _Alloc>
131 using _Uses =
typename
134#if __cplusplus >= 201703L
139 "value_type must be the same as the underlying container");
144 typedef typename _Sequence::value_type value_type;
145 typedef typename _Sequence::reference reference;
146 typedef typename _Sequence::const_reference const_reference;
147 typedef typename _Sequence::size_type size_type;
148 typedef _Sequence container_type;
159#if __cplusplus < 201103L
161 stack(
const _Sequence& __c = _Sequence())
164 template<
typename _Seq = _Sequence,
typename _Requires =
typename
170 stack(
const _Sequence& __c)
174 stack(_Sequence&& __c)
177#ifdef __glibcxx_adaptor_iterator_pair_constructor
178 template<
typename _InputIterator,
179 typename = _RequireInputIter<_InputIterator>>
180 stack(_InputIterator __first, _InputIterator __last)
181 : c(__first, __last) { }
184#if __glibcxx_containers_ranges
189 template<__detail::__container_compatible_range<_Tp> _Rg>
190 stack(from_range_t, _Rg&& __rg)
191 : c(ranges::to<_Sequence>(
std::
forward<_Rg>(__rg)))
198 template<__detail::__container_compatible_range<_Tp> _Rg,
200 stack(from_range_t, _Rg&& __rg,
const _Alloc& __a)
201 : c(ranges::to<_Sequence>(
std::
forward<_Rg>(__rg), __a))
205 template<
typename _Alloc,
typename _Requires = _Uses<_Alloc>>
207 stack(
const _Alloc& __a)
210 template<
typename _Alloc,
typename _Requires = _Uses<_Alloc>>
211 stack(
const _Sequence& __c,
const _Alloc& __a)
214 template<
typename _Alloc,
typename _Requires = _Uses<_Alloc>>
215 stack(_Sequence&& __c,
const _Alloc& __a)
218 template<
typename _Alloc,
typename _Requires = _Uses<_Alloc>>
222 template<
typename _Alloc,
typename _Requires = _Uses<_Alloc>>
226#if __cplusplus > 202002L
227 template<
typename _InputIterator,
typename _Alloc,
228 typename = _RequireInputIter<_InputIterator>,
229 typename = _Uses<_Alloc>>
230 stack(_InputIterator __first, _InputIterator __last,
const _Alloc& __a)
231 : c(__first, __last, __a) { }
238 _GLIBCXX_NODISCARD
bool
240 {
return c.empty(); }
256 __glibcxx_requires_nonempty();
268 __glibcxx_requires_nonempty();
283 { c.push_back(__x); }
285#if __cplusplus >= 201103L
287 push(value_type&& __x)
290#if __cplusplus > 201402L
291 template<
typename... _Args>
293 emplace(_Args&&... __args)
294 {
return c.emplace_back(std::forward<_Args>(__args)...); }
296 template<
typename... _Args>
298 emplace(_Args&&... __args)
299 { c.emplace_back(std::forward<_Args>(__args)...); }
303#if __glibcxx_containers_ranges
304 template<__detail::__container_compatible_range<_Tp> _Rg>
306 push_range(_Rg&& __rg)
308 if constexpr (
requires { c.append_range(std::forward<_Rg>(__rg)); })
309 c.append_range(std::forward<_Rg>(__rg));
329 __glibcxx_requires_nonempty();
333#if __cplusplus >= 201103L
336#if __cplusplus > 201402L || !defined(__STRICT_ANSI__)
337 noexcept(__is_nothrow_swappable<_Sequence>::value)
339 noexcept(__is_nothrow_swappable<_Tp>::value)
348#if __cpp_deduction_guides >= 201606
349 template<
typename _Container,
350 typename = _RequireNotAllocator<_Container>>
351 stack(_Container) -> stack<typename _Container::value_type, _Container>;
353 template<
typename _Container,
typename _Allocator,
354 typename = _RequireNotAllocator<_Container>>
355 stack(_Container, _Allocator)
356 -> stack<typename _Container::value_type, _Container>;
358#ifdef __glibcxx_adaptor_iterator_pair_constructor
359 template<
typename _InputIterator,
361 =
typename iterator_traits<_InputIterator>::value_type,
362 typename = _RequireInputIter<_InputIterator>>
363 stack(_InputIterator, _InputIterator) -> stack<_ValT>;
365 template<
typename _InputIterator,
typename _Allocator,
367 =
typename iterator_traits<_InputIterator>::value_type,
368 typename = _RequireInputIter<_InputIterator>,
369 typename = _RequireAllocator<_Allocator>>
370 stack(_InputIterator, _InputIterator, _Allocator)
371 -> stack<_ValT, deque<_ValT, _Allocator>>;
374#if __glibcxx_containers_ranges
375 template<ranges::input_range _Rg>
376 stack(from_range_t, _Rg&&) -> stack<ranges::range_value_t<_Rg>>;
378 template<ranges::input_range _Rg, __allocator_like _Alloc>
379 stack(from_range_t, _Rg&&, _Alloc)
380 -> stack<ranges::range_value_t<_Rg>,
381 deque<ranges::range_value_t<_Rg>, _Alloc>>;
397 template<
typename _Tp,
typename _Seq>
401 {
return __x.c == __y.c; }
416 template<
typename _Tp,
typename _Seq>
420 {
return __x.c < __y.c; }
423 template<
typename _Tp,
typename _Seq>
427 {
return !(__x == __y); }
430 template<
typename _Tp,
typename _Seq>
434 {
return __y < __x; }
437 template<
typename _Tp,
typename _Seq>
441 {
return !(__y < __x); }
444 template<
typename _Tp,
typename _Seq>
448 {
return !(__x < __y); }
450#if __cpp_lib_three_way_comparison
451 template<
typename _Tp, three_way_comparable _Seq>
453 inline compare_three_way_result_t<_Seq>
454 operator<=>(
const stack<_Tp, _Seq>& __x,
const stack<_Tp, _Seq>& __y)
455 {
return __x.c <=> __y.c; }
458#if __cplusplus >= 201103L
459 template<
typename _Tp,
typename _Seq>
461#if __cplusplus > 201402L || !defined(__STRICT_ANSI__)
463 typename enable_if<__is_swappable<_Seq>::value>::type
467 swap(stack<_Tp, _Seq>& __x, stack<_Tp, _Seq>& __y)
468 noexcept(
noexcept(__x.swap(__y)))
471 template<
typename _Tp,
typename _Seq,
typename _Alloc>
472 struct uses_allocator<stack<_Tp, _Seq>, _Alloc>
473 :
public uses_allocator<_Seq, _Alloc>::type { };
476_GLIBCXX_END_NAMESPACE_VERSION
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
constexpr _Tp && forward(typename std::remove_reference< _Tp >::type &__t) noexcept
Forward an lvalue.
constexpr back_insert_iterator< _Container > back_inserter(_Container &__x)
ISO C++ entities toplevel namespace is std.
typename __detail::__cmp3way_res_impl< _Tp, _Up >::type compare_three_way_result_t
[cmp.result], result of three-way comparison
Define a member typedef type only if a boolean constant is true.
A standard container giving FILO behavior.
void pop()
Removes first element.
void push(const value_type &__x)
Add data to the top of the stack.
const_reference top() const
stack()
Default constructor creates no elements.