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 __cplusplus >= 201103L 120 template<
typename _Alloc>
121 using _Uses =
typename 124 #if __cplusplus >= 201703L 129 "value_type must be the same as the underlying container");
134 typedef typename _Sequence::value_type value_type;
135 typedef typename _Sequence::reference reference;
136 typedef typename _Sequence::const_reference const_reference;
137 typedef typename _Sequence::size_type size_type;
138 typedef _Sequence container_type;
149 #if __cplusplus < 201103L 151 stack(
const _Sequence& __c = _Sequence())
154 template<
typename _Seq = _Sequence,
typename _Requires =
typename 160 stack(
const _Sequence& __c)
164 stack(_Sequence&& __c)
165 : c(
std::move(__c)) { }
167 template<
typename _Alloc,
typename _Requires = _Uses<_Alloc>>
169 stack(
const _Alloc& __a)
172 template<
typename _Alloc,
typename _Requires = _Uses<_Alloc>>
173 stack(
const _Sequence& __c,
const _Alloc& __a)
176 template<
typename _Alloc,
typename _Requires = _Uses<_Alloc>>
177 stack(_Sequence&& __c,
const _Alloc& __a)
178 : c(
std::move(__c), __a) { }
180 template<
typename _Alloc,
typename _Requires = _Uses<_Alloc>>
184 template<
typename _Alloc,
typename _Requires = _Uses<_Alloc>>
186 : c(
std::move(__q.c), __a) { }
192 _GLIBCXX_NODISCARD
bool 194 {
return c.empty(); }
208 __glibcxx_requires_nonempty();
219 __glibcxx_requires_nonempty();
234 { c.push_back(__x); }
236 #if __cplusplus >= 201103L 238 push(value_type&& __x)
239 { c.push_back(std::move(__x)); }
241 #if __cplusplus > 201402L 242 template<
typename... _Args>
244 emplace(_Args&&... __args)
245 {
return c.emplace_back(std::forward<_Args>(__args)...); }
247 template<
typename... _Args>
249 emplace(_Args&&... __args)
250 { c.emplace_back(std::forward<_Args>(__args)...); }
268 __glibcxx_requires_nonempty();
272 #if __cplusplus >= 201103L 275 #if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 276 noexcept(__is_nothrow_swappable<_Sequence>::value)
278 noexcept(__is_nothrow_swappable<_Tp>::value)
284 #endif // __cplusplus >= 201103L 287 #if __cpp_deduction_guides >= 201606 288 template<
typename _Container,
289 typename = _RequireNotAllocator<_Container>>
290 stack(_Container) -> stack<typename _Container::value_type, _Container>;
292 template<
typename _Container,
typename _Allocator,
293 typename = _RequireNotAllocator<_Container>,
294 typename = _RequireAllocator<_Allocator>>
295 stack(_Container, _Allocator)
296 -> stack<typename _Container::value_type, _Container>;
311 template<
typename _Tp,
typename _Seq>
314 {
return __x.c == __y.c; }
329 template<
typename _Tp,
typename _Seq>
332 {
return __x.c < __y.c; }
335 template<
typename _Tp,
typename _Seq>
338 {
return !(__x == __y); }
341 template<
typename _Tp,
typename _Seq>
344 {
return __y < __x; }
347 template<
typename _Tp,
typename _Seq>
350 {
return !(__y < __x); }
353 template<
typename _Tp,
typename _Seq>
356 {
return !(__x < __y); }
358 #if __cplusplus >= 201103L 359 template<
typename _Tp,
typename _Seq>
361 #if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 363 typename enable_if<__is_swappable<_Seq>::value>::type
367 swap(stack<_Tp, _Seq>& __x, stack<_Tp, _Seq>& __y)
368 noexcept(noexcept(__x.swap(__y)))
371 template<
typename _Tp,
typename _Seq,
typename _Alloc>
372 struct uses_allocator<stack<_Tp, _Seq>, _Alloc>
373 :
public uses_allocator<_Seq, _Alloc>::type { };
374 #endif // __cplusplus >= 201103L 376 _GLIBCXX_END_NAMESPACE_VERSION
_GLIBCXX_NODISCARD bool empty() const
ISO C++ entities toplevel namespace is std.
stack()
Default constructor creates no elements.
const_reference top() const
void pop()
Removes first element.
void push(const value_type &__x)
Add data to the top of the stack.
A standard container giving FILO behavior.
Define a member typedef type only if a boolean constant is true.