Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | // -*- C++ -*- |
| 2 | //===---------------------------- stack -----------------------------------===// |
| 3 | // |
Chandler Carruth | d201210 | 2019-01-19 10:56:40 +0000 | [diff] [blame] | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | // See https://llvm.org/LICENSE.txt for license information. |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #ifndef _LIBCPP_STACK |
| 11 | #define _LIBCPP_STACK |
| 12 | |
| 13 | /* |
| 14 | stack synopsis |
| 15 | |
| 16 | namespace std |
| 17 | { |
| 18 | |
| 19 | template <class T, class Container = deque<T>> |
| 20 | class stack |
| 21 | { |
| 22 | public: |
| 23 | typedef Container container_type; |
| 24 | typedef typename container_type::value_type value_type; |
| 25 | typedef typename container_type::reference reference; |
| 26 | typedef typename container_type::const_reference const_reference; |
| 27 | typedef typename container_type::size_type size_type; |
| 28 | |
| 29 | protected: |
| 30 | container_type c; |
| 31 | |
| 32 | public: |
Howard Hinnant | e0da4a1 | 2011-06-04 22:09:19 +0000 | [diff] [blame] | 33 | stack() = default; |
| 34 | ~stack() = default; |
| 35 | |
| 36 | stack(const stack& q) = default; |
| 37 | stack(stack&& q) = default; |
| 38 | |
| 39 | stack& operator=(const stack& q) = default; |
| 40 | stack& operator=(stack&& q) = default; |
| 41 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 42 | explicit stack(const container_type& c); |
| 43 | explicit stack(container_type&& c); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 44 | template <class Alloc> explicit stack(const Alloc& a); |
| 45 | template <class Alloc> stack(const container_type& c, const Alloc& a); |
| 46 | template <class Alloc> stack(container_type&& c, const Alloc& a); |
Howard Hinnant | e0da4a1 | 2011-06-04 22:09:19 +0000 | [diff] [blame] | 47 | template <class Alloc> stack(const stack& c, const Alloc& a); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 48 | template <class Alloc> stack(stack&& c, const Alloc& a); |
| 49 | |
| 50 | bool empty() const; |
| 51 | size_type size() const; |
| 52 | reference top(); |
| 53 | const_reference top() const; |
| 54 | |
| 55 | void push(const value_type& x); |
| 56 | void push(value_type&& x); |
Marshall Clow | ea52cc4 | 2017-01-24 23:09:12 +0000 | [diff] [blame] | 57 | template <class... Args> reference emplace(Args&&... args); // reference in C++17 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 58 | void pop(); |
| 59 | |
Eric Fiselier | 6bfed25 | 2016-04-21 23:38:59 +0000 | [diff] [blame] | 60 | void swap(stack& c) noexcept(is_nothrow_swappable_v<Container>) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 61 | }; |
| 62 | |
Marshall Clow | 592d995 | 2018-05-22 01:57:53 +0000 | [diff] [blame] | 63 | template<class Container> |
| 64 | stack(Container) -> stack<typename Container::value_type, Container>; // C++17 |
Louis Dionne | 173f29e | 2019-05-29 16:01:36 +0000 | [diff] [blame] | 65 | |
| 66 | template<class Container, class Allocator> |
Marshall Clow | 592d995 | 2018-05-22 01:57:53 +0000 | [diff] [blame] | 67 | stack(Container, Allocator) -> stack<typename Container::value_type, Container>; // C++17 |
| 68 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 69 | template <class T, class Container> |
| 70 | bool operator==(const stack<T, Container>& x, const stack<T, Container>& y); |
| 71 | template <class T, class Container> |
| 72 | bool operator< (const stack<T, Container>& x, const stack<T, Container>& y); |
| 73 | template <class T, class Container> |
| 74 | bool operator!=(const stack<T, Container>& x, const stack<T, Container>& y); |
| 75 | template <class T, class Container> |
| 76 | bool operator> (const stack<T, Container>& x, const stack<T, Container>& y); |
| 77 | template <class T, class Container> |
| 78 | bool operator>=(const stack<T, Container>& x, const stack<T, Container>& y); |
| 79 | template <class T, class Container> |
| 80 | bool operator<=(const stack<T, Container>& x, const stack<T, Container>& y); |
| 81 | |
| 82 | template <class T, class Container> |
Howard Hinnant | e0da4a1 | 2011-06-04 22:09:19 +0000 | [diff] [blame] | 83 | void swap(stack<T, Container>& x, stack<T, Container>& y) |
| 84 | noexcept(noexcept(x.swap(y))); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 85 | |
| 86 | } // std |
| 87 | |
| 88 | */ |
| 89 | |
| 90 | #include <__config> |
Christopher Di Bella | 41f26e8 | 2021-06-05 02:47:47 +0000 | [diff] [blame] | 91 | #include <__utility/forward.h> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 92 | #include <deque> |
| 93 | |
Howard Hinnant | aaaa52b | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 94 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 95 | #pragma GCC system_header |
Howard Hinnant | aaaa52b | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 96 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 97 | |
| 98 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 99 | |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 100 | template <class _Tp, class _Container = deque<_Tp> > class _LIBCPP_TEMPLATE_VIS stack; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 101 | |
| 102 | template <class _Tp, class _Container> |
Howard Hinnant | a54386e | 2012-09-14 00:39:16 +0000 | [diff] [blame] | 103 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 104 | bool |
| 105 | operator==(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y); |
| 106 | |
| 107 | template <class _Tp, class _Container> |
Howard Hinnant | a54386e | 2012-09-14 00:39:16 +0000 | [diff] [blame] | 108 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 109 | bool |
| 110 | operator< (const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y); |
| 111 | |
Marshall Clow | 9e1b845 | 2015-02-18 17:51:56 +0000 | [diff] [blame] | 112 | template <class _Tp, class _Container /*= deque<_Tp>*/> |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 113 | class _LIBCPP_TEMPLATE_VIS stack |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 114 | { |
| 115 | public: |
| 116 | typedef _Container container_type; |
| 117 | typedef typename container_type::value_type value_type; |
| 118 | typedef typename container_type::reference reference; |
| 119 | typedef typename container_type::const_reference const_reference; |
| 120 | typedef typename container_type::size_type size_type; |
Marshall Clow | b8825f0 | 2016-03-14 17:58:11 +0000 | [diff] [blame] | 121 | static_assert((is_same<_Tp, value_type>::value), "" ); |
Louis Dionne | 173f29e | 2019-05-29 16:01:36 +0000 | [diff] [blame] | 122 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 123 | protected: |
| 124 | container_type c; |
| 125 | |
| 126 | public: |
Howard Hinnant | 186dca8 | 2010-09-23 17:31:07 +0000 | [diff] [blame] | 127 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | e0da4a1 | 2011-06-04 22:09:19 +0000 | [diff] [blame] | 128 | stack() |
| 129 | _NOEXCEPT_(is_nothrow_default_constructible<container_type>::value) |
| 130 | : c() {} |
| 131 | |
| 132 | _LIBCPP_INLINE_VISIBILITY |
| 133 | stack(const stack& __q) : c(__q.c) {} |
| 134 | |
Eric Fiselier | 33cc2f0 | 2017-04-18 21:16:26 +0000 | [diff] [blame] | 135 | _LIBCPP_INLINE_VISIBILITY |
| 136 | stack& operator=(const stack& __q) {c = __q.c; return *this;} |
| 137 | |
| 138 | |
| 139 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | e0da4a1 | 2011-06-04 22:09:19 +0000 | [diff] [blame] | 140 | _LIBCPP_INLINE_VISIBILITY |
| 141 | stack(stack&& __q) |
| 142 | _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value) |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 143 | : c(_VSTD::move(__q.c)) {} |
Howard Hinnant | e0da4a1 | 2011-06-04 22:09:19 +0000 | [diff] [blame] | 144 | |
| 145 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | e0da4a1 | 2011-06-04 22:09:19 +0000 | [diff] [blame] | 146 | stack& operator=(stack&& __q) |
| 147 | _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value) |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 148 | {c = _VSTD::move(__q.c); return *this;} |
Eric Fiselier | 33cc2f0 | 2017-04-18 21:16:26 +0000 | [diff] [blame] | 149 | |
| 150 | _LIBCPP_INLINE_VISIBILITY |
| 151 | explicit stack(container_type&& __c) : c(_VSTD::move(__c)) {} |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 152 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | e0da4a1 | 2011-06-04 22:09:19 +0000 | [diff] [blame] | 153 | |
Howard Hinnant | 186dca8 | 2010-09-23 17:31:07 +0000 | [diff] [blame] | 154 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 155 | explicit stack(const container_type& __c) : c(__c) {} |
Eric Fiselier | 33cc2f0 | 2017-04-18 21:16:26 +0000 | [diff] [blame] | 156 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 157 | template <class _Alloc> |
Howard Hinnant | 186dca8 | 2010-09-23 17:31:07 +0000 | [diff] [blame] | 158 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 159 | explicit stack(const _Alloc& __a, |
Arthur O'Dwyer | 5622676 | 2021-03-03 23:02:20 -0500 | [diff] [blame] | 160 | _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 161 | : c(__a) {} |
| 162 | template <class _Alloc> |
Howard Hinnant | 186dca8 | 2010-09-23 17:31:07 +0000 | [diff] [blame] | 163 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 164 | stack(const container_type& __c, const _Alloc& __a, |
Arthur O'Dwyer | 5622676 | 2021-03-03 23:02:20 -0500 | [diff] [blame] | 165 | _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 166 | : c(__c, __a) {} |
| 167 | template <class _Alloc> |
Howard Hinnant | 186dca8 | 2010-09-23 17:31:07 +0000 | [diff] [blame] | 168 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 169 | stack(const stack& __s, const _Alloc& __a, |
Arthur O'Dwyer | 5622676 | 2021-03-03 23:02:20 -0500 | [diff] [blame] | 170 | _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 171 | : c(__s.c, __a) {} |
Eric Fiselier | 33cc2f0 | 2017-04-18 21:16:26 +0000 | [diff] [blame] | 172 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 173 | template <class _Alloc> |
Howard Hinnant | 186dca8 | 2010-09-23 17:31:07 +0000 | [diff] [blame] | 174 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 175 | stack(container_type&& __c, const _Alloc& __a, |
Arthur O'Dwyer | 5622676 | 2021-03-03 23:02:20 -0500 | [diff] [blame] | 176 | _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0) |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 177 | : c(_VSTD::move(__c), __a) {} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 178 | template <class _Alloc> |
Howard Hinnant | 186dca8 | 2010-09-23 17:31:07 +0000 | [diff] [blame] | 179 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 180 | stack(stack&& __s, const _Alloc& __a, |
Arthur O'Dwyer | 5622676 | 2021-03-03 23:02:20 -0500 | [diff] [blame] | 181 | _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0) |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 182 | : c(_VSTD::move(__s.c), __a) {} |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 183 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 184 | |
Marshall Clow | 425f575 | 2017-11-15 05:51:26 +0000 | [diff] [blame] | 185 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 186 | bool empty() const {return c.empty();} |
Howard Hinnant | 186dca8 | 2010-09-23 17:31:07 +0000 | [diff] [blame] | 187 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 188 | size_type size() const {return c.size();} |
Howard Hinnant | 186dca8 | 2010-09-23 17:31:07 +0000 | [diff] [blame] | 189 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 190 | reference top() {return c.back();} |
Howard Hinnant | 186dca8 | 2010-09-23 17:31:07 +0000 | [diff] [blame] | 191 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 192 | const_reference top() const {return c.back();} |
| 193 | |
Howard Hinnant | 186dca8 | 2010-09-23 17:31:07 +0000 | [diff] [blame] | 194 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 195 | void push(const value_type& __v) {c.push_back(__v);} |
Eric Fiselier | 33cc2f0 | 2017-04-18 21:16:26 +0000 | [diff] [blame] | 196 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | 186dca8 | 2010-09-23 17:31:07 +0000 | [diff] [blame] | 197 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 198 | void push(value_type&& __v) {c.push_back(_VSTD::move(__v));} |
Eric Fiselier | 33cc2f0 | 2017-04-18 21:16:26 +0000 | [diff] [blame] | 199 | |
Howard Hinnant | 186dca8 | 2010-09-23 17:31:07 +0000 | [diff] [blame] | 200 | template <class... _Args> |
| 201 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | ea52cc4 | 2017-01-24 23:09:12 +0000 | [diff] [blame] | 202 | #if _LIBCPP_STD_VER > 14 |
Marshall Clow | 8874685 | 2018-01-24 22:42:25 +0000 | [diff] [blame] | 203 | decltype(auto) emplace(_Args&&... __args) |
Eric Fiselier | 34ba5b9 | 2016-07-21 03:20:17 +0000 | [diff] [blame] | 204 | { return c.emplace_back(_VSTD::forward<_Args>(__args)...);} |
Marshall Clow | ea52cc4 | 2017-01-24 23:09:12 +0000 | [diff] [blame] | 205 | #else |
| 206 | void emplace(_Args&&... __args) |
| 207 | { c.emplace_back(_VSTD::forward<_Args>(__args)...);} |
| 208 | #endif |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 209 | #endif // _LIBCPP_CXX03_LANG |
Eric Fiselier | 33cc2f0 | 2017-04-18 21:16:26 +0000 | [diff] [blame] | 210 | |
Howard Hinnant | 186dca8 | 2010-09-23 17:31:07 +0000 | [diff] [blame] | 211 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 212 | void pop() {c.pop_back();} |
| 213 | |
Howard Hinnant | 186dca8 | 2010-09-23 17:31:07 +0000 | [diff] [blame] | 214 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 215 | void swap(stack& __s) |
Howard Hinnant | e0da4a1 | 2011-06-04 22:09:19 +0000 | [diff] [blame] | 216 | _NOEXCEPT_(__is_nothrow_swappable<container_type>::value) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 217 | { |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 218 | using _VSTD::swap; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 219 | swap(c, __s.c); |
| 220 | } |
| 221 | |
| 222 | template <class T1, class _C1> |
| 223 | friend |
| 224 | bool |
| 225 | operator==(const stack<T1, _C1>& __x, const stack<T1, _C1>& __y); |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 226 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 227 | template <class T1, class _C1> |
| 228 | friend |
| 229 | bool |
| 230 | operator< (const stack<T1, _C1>& __x, const stack<T1, _C1>& __y); |
| 231 | }; |
| 232 | |
Marshall Clow | 592d995 | 2018-05-22 01:57:53 +0000 | [diff] [blame] | 233 | #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES |
| 234 | template<class _Container, |
Arthur O'Dwyer | 5622676 | 2021-03-03 23:02:20 -0500 | [diff] [blame] | 235 | class = _EnableIf<!__is_allocator<_Container>::value> |
Marshall Clow | 592d995 | 2018-05-22 01:57:53 +0000 | [diff] [blame] | 236 | > |
| 237 | stack(_Container) |
| 238 | -> stack<typename _Container::value_type, _Container>; |
Louis Dionne | 173f29e | 2019-05-29 16:01:36 +0000 | [diff] [blame] | 239 | |
Marshall Clow | 592d995 | 2018-05-22 01:57:53 +0000 | [diff] [blame] | 240 | template<class _Container, |
| 241 | class _Alloc, |
Arthur O'Dwyer | 5622676 | 2021-03-03 23:02:20 -0500 | [diff] [blame] | 242 | class = _EnableIf<!__is_allocator<_Container>::value>, |
Arthur O'Dwyer | 9b9662f | 2021-03-01 17:08:24 -0500 | [diff] [blame] | 243 | class = _EnableIf<uses_allocator<_Container, _Alloc>::value> |
Louis Dionne | 173f29e | 2019-05-29 16:01:36 +0000 | [diff] [blame] | 244 | > |
Marshall Clow | 592d995 | 2018-05-22 01:57:53 +0000 | [diff] [blame] | 245 | stack(_Container, _Alloc) |
| 246 | -> stack<typename _Container::value_type, _Container>; |
| 247 | #endif |
| 248 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 249 | template <class _Tp, class _Container> |
Howard Hinnant | 186dca8 | 2010-09-23 17:31:07 +0000 | [diff] [blame] | 250 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 251 | bool |
| 252 | operator==(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y) |
| 253 | { |
| 254 | return __x.c == __y.c; |
| 255 | } |
| 256 | |
| 257 | template <class _Tp, class _Container> |
Howard Hinnant | 186dca8 | 2010-09-23 17:31:07 +0000 | [diff] [blame] | 258 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 259 | bool |
| 260 | operator< (const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y) |
| 261 | { |
| 262 | return __x.c < __y.c; |
| 263 | } |
| 264 | |
| 265 | template <class _Tp, class _Container> |
Howard Hinnant | 186dca8 | 2010-09-23 17:31:07 +0000 | [diff] [blame] | 266 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 267 | bool |
| 268 | operator!=(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y) |
| 269 | { |
| 270 | return !(__x == __y); |
| 271 | } |
| 272 | |
| 273 | template <class _Tp, class _Container> |
Howard Hinnant | 186dca8 | 2010-09-23 17:31:07 +0000 | [diff] [blame] | 274 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 275 | bool |
| 276 | operator> (const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y) |
| 277 | { |
| 278 | return __y < __x; |
| 279 | } |
| 280 | |
| 281 | template <class _Tp, class _Container> |
Howard Hinnant | 186dca8 | 2010-09-23 17:31:07 +0000 | [diff] [blame] | 282 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 283 | bool |
| 284 | operator>=(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y) |
| 285 | { |
| 286 | return !(__x < __y); |
| 287 | } |
| 288 | |
| 289 | template <class _Tp, class _Container> |
Howard Hinnant | 186dca8 | 2010-09-23 17:31:07 +0000 | [diff] [blame] | 290 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 291 | bool |
| 292 | operator<=(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y) |
| 293 | { |
| 294 | return !(__y < __x); |
| 295 | } |
| 296 | |
| 297 | template <class _Tp, class _Container> |
Howard Hinnant | 186dca8 | 2010-09-23 17:31:07 +0000 | [diff] [blame] | 298 | inline _LIBCPP_INLINE_VISIBILITY |
Arthur O'Dwyer | 5622676 | 2021-03-03 23:02:20 -0500 | [diff] [blame] | 299 | _EnableIf<__is_swappable<_Container>::value, void> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 300 | swap(stack<_Tp, _Container>& __x, stack<_Tp, _Container>& __y) |
Howard Hinnant | e0da4a1 | 2011-06-04 22:09:19 +0000 | [diff] [blame] | 301 | _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 302 | { |
| 303 | __x.swap(__y); |
| 304 | } |
| 305 | |
| 306 | template <class _Tp, class _Container, class _Alloc> |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 307 | struct _LIBCPP_TEMPLATE_VIS uses_allocator<stack<_Tp, _Container>, _Alloc> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 308 | : public uses_allocator<_Container, _Alloc> |
| 309 | { |
| 310 | }; |
| 311 | |
| 312 | _LIBCPP_END_NAMESPACE_STD |
| 313 | |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 314 | #endif // _LIBCPP_STACK |