57 #define _STL_STACK_H 1
61 #if __cplusplus >= 201103L
62 # include <bits/uses_allocator.h>
65 namespace std _GLIBCXX_VISIBILITY(default)
67 _GLIBCXX_BEGIN_NAMESPACE_VERSION
98 template<
typename _Tp,
typename _Sequence = deque<_Tp> >
101 #ifdef _GLIBCXX_CONCEPT_CHECKS
103 typedef typename _Sequence::value_type _Sequence_value_type;
104 # if __cplusplus < 201103L
105 __glibcxx_class_requires(_Tp, _SGIAssignableConcept)
106 __glibcxx_class_requires(_Sequence, _BackInsertionSequenceConcept)
108 __glibcxx_class_requires2(_Tp, _Sequence_value_type, _SameTypeConcept)
111 template<
typename _Tp1,
typename _Seq1>
115 template<
typename _Tp1,
typename _Seq1>
119 #if __cpp_lib_three_way_comparison
120 template<
typename _Tp1, three_way_comparable _Seq1>
125 #if __cplusplus >= 201103L
126 template<
typename _Alloc>
127 using _Uses =
typename
130 #if __cplusplus >= 201703L
135 "value_type must be the same as the underlying container");
140 typedef typename _Sequence::value_type value_type;
141 typedef typename _Sequence::reference reference;
142 typedef typename _Sequence::const_reference const_reference;
143 typedef typename _Sequence::size_type size_type;
144 typedef _Sequence container_type;
155 #if __cplusplus < 201103L
157 stack(
const _Sequence& __c = _Sequence())
160 template<
typename _Seq = _Sequence,
typename _Requires =
typename
166 stack(
const _Sequence& __c)
170 stack(_Sequence&& __c)
173 #if __cplusplus > 202002L
174 #define __cpp_lib_adaptor_iterator_pair_constructor 202106L
176 template<
typename _InputIterator,
177 typename = _RequireInputIter<_InputIterator>>
178 stack(_InputIterator __first, _InputIterator __last)
179 : c(__first, __last) { }
183 template<
typename _Alloc,
typename _Requires = _Uses<_Alloc>>
185 stack(
const _Alloc& __a)
188 template<
typename _Alloc,
typename _Requires = _Uses<_Alloc>>
189 stack(
const _Sequence& __c,
const _Alloc& __a)
192 template<
typename _Alloc,
typename _Requires = _Uses<_Alloc>>
193 stack(_Sequence&& __c,
const _Alloc& __a)
196 template<
typename _Alloc,
typename _Requires = _Uses<_Alloc>>
200 template<
typename _Alloc,
typename _Requires = _Uses<_Alloc>>
204 #if __cplusplus > 202002L
205 template<
typename _InputIterator,
typename _Alloc,
206 typename = _RequireInputIter<_InputIterator>,
207 typename = _Uses<_Alloc>>
208 stack(_InputIterator __first, _InputIterator __last,
const _Alloc& __a)
209 : c(__first, __last, __a) { }
216 _GLIBCXX_NODISCARD
bool
218 {
return c.empty(); }
234 __glibcxx_requires_nonempty();
246 __glibcxx_requires_nonempty();
261 { c.push_back(__x); }
263 #if __cplusplus >= 201103L
265 push(value_type&& __x)
268 #if __cplusplus > 201402L
269 template<
typename... _Args>
271 emplace(_Args&&... __args)
272 {
return c.emplace_back(std::forward<_Args>(__args)...); }
274 template<
typename... _Args>
276 emplace(_Args&&... __args)
277 { c.emplace_back(std::forward<_Args>(__args)...); }
295 __glibcxx_requires_nonempty();
299 #if __cplusplus >= 201103L
302 #if __cplusplus > 201402L || !defined(__STRICT_ANSI__)
303 noexcept(__is_nothrow_swappable<_Sequence>::value)
305 noexcept(__is_nothrow_swappable<_Tp>::value)
314 #if __cpp_deduction_guides >= 201606
315 template<
typename _Container,
316 typename = _RequireNotAllocator<_Container>>
317 stack(_Container) -> stack<typename _Container::value_type, _Container>;
319 template<
typename _Container,
typename _Allocator,
320 typename = _RequireNotAllocator<_Container>>
321 stack(_Container, _Allocator)
322 -> stack<typename _Container::value_type, _Container>;
324 #ifdef __cpp_lib_adaptor_iterator_pair_constructor
325 template<
typename _InputIterator,
327 =
typename iterator_traits<_InputIterator>::value_type,
328 typename = _RequireInputIter<_InputIterator>>
329 stack(_InputIterator, _InputIterator) -> stack<_ValT>;
331 template<
typename _InputIterator,
typename _Allocator,
333 =
typename iterator_traits<_InputIterator>::value_type,
334 typename = _RequireInputIter<_InputIterator>,
335 typename = _RequireAllocator<_Allocator>>
336 stack(_InputIterator, _InputIterator, _Allocator)
337 -> stack<_ValT, deque<_ValT, _Allocator>>;
353 template<
typename _Tp,
typename _Seq>
357 {
return __x.c == __y.c; }
372 template<
typename _Tp,
typename _Seq>
376 {
return __x.c < __y.c; }
379 template<
typename _Tp,
typename _Seq>
383 {
return !(__x == __y); }
386 template<
typename _Tp,
typename _Seq>
390 {
return __y < __x; }
393 template<
typename _Tp,
typename _Seq>
397 {
return !(__y < __x); }
400 template<
typename _Tp,
typename _Seq>
404 {
return !(__x < __y); }
406 #if __cpp_lib_three_way_comparison
407 template<
typename _Tp, three_way_comparable _Seq>
409 inline compare_three_way_result_t<_Seq>
410 operator<=>(
const stack<_Tp, _Seq>& __x,
const stack<_Tp, _Seq>& __y)
411 {
return __x.c <=> __y.c; }
414 #if __cplusplus >= 201103L
415 template<
typename _Tp,
typename _Seq>
417 #if __cplusplus > 201402L || !defined(__STRICT_ANSI__)
419 typename enable_if<__is_swappable<_Seq>::value>::type
423 swap(stack<_Tp, _Seq>& __x, stack<_Tp, _Seq>& __y)
424 noexcept(noexcept(__x.swap(__y)))
427 template<
typename _Tp,
typename _Seq,
typename _Alloc>
428 struct uses_allocator<stack<_Tp, _Seq>, _Alloc>
429 :
public uses_allocator<_Seq, _Alloc>::type { };
432 _GLIBCXX_END_NAMESPACE_VERSION
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
void swap(any &__x, any &__y) noexcept
Exchange the states of two any objects.
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.