Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | // -*- C++ -*- |
| 2 | //===---------------------------- stack -----------------------------------===// |
| 3 | // |
Howard Hinnant | f5256e1 | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 4 | // The LLVM Compiler Infrastructure |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 5 | // |
Howard Hinnant | b64f8b0 | 2010-11-16 22:09:02 +0000 | [diff] [blame] | 6 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 7 | // Source Licenses. See LICENSE.TXT for details. |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 8 | // |
| 9 | //===----------------------------------------------------------------------===// |
| 10 | |
| 11 | #ifndef _LIBCPP_STACK |
| 12 | #define _LIBCPP_STACK |
| 13 | |
| 14 | /* |
| 15 | stack synopsis |
| 16 | |
| 17 | namespace std |
| 18 | { |
| 19 | |
| 20 | template <class T, class Container = deque<T>> |
| 21 | class stack |
| 22 | { |
| 23 | public: |
| 24 | typedef Container container_type; |
| 25 | typedef typename container_type::value_type value_type; |
| 26 | typedef typename container_type::reference reference; |
| 27 | typedef typename container_type::const_reference const_reference; |
| 28 | typedef typename container_type::size_type size_type; |
| 29 | |
| 30 | protected: |
| 31 | container_type c; |
| 32 | |
| 33 | public: |
Howard Hinnant | 58cd823 | 2011-06-04 22:09:19 +0000 | [diff] [blame] | 34 | stack() = default; |
| 35 | ~stack() = default; |
| 36 | |
| 37 | stack(const stack& q) = default; |
| 38 | stack(stack&& q) = default; |
| 39 | |
| 40 | stack& operator=(const stack& q) = default; |
| 41 | stack& operator=(stack&& q) = default; |
| 42 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 43 | explicit stack(const container_type& c); |
| 44 | explicit stack(container_type&& c); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 45 | template <class Alloc> explicit stack(const Alloc& a); |
| 46 | template <class Alloc> stack(const container_type& c, const Alloc& a); |
| 47 | template <class Alloc> stack(container_type&& c, const Alloc& a); |
Howard Hinnant | 58cd823 | 2011-06-04 22:09:19 +0000 | [diff] [blame] | 48 | template <class Alloc> stack(const stack& c, const Alloc& a); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 49 | template <class Alloc> stack(stack&& c, const Alloc& a); |
| 50 | |
| 51 | bool empty() const; |
| 52 | size_type size() const; |
| 53 | reference top(); |
| 54 | const_reference top() const; |
| 55 | |
| 56 | void push(const value_type& x); |
| 57 | void push(value_type&& x); |
Marshall Clow | 4e42dc9 | 2017-01-24 23:09:12 +0000 | [diff] [blame] | 58 | template <class... Args> reference emplace(Args&&... args); // reference in C++17 |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 59 | void pop(); |
| 60 | |
Eric Fiselier | 8f1e73d | 2016-04-21 23:38:59 +0000 | [diff] [blame] | 61 | void swap(stack& c) noexcept(is_nothrow_swappable_v<Container>) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 62 | }; |
| 63 | |
Marshall Clow | 0e5d707 | 2018-05-22 01:57:53 +0000 | [diff] [blame] | 64 | template<class Container> |
| 65 | stack(Container) -> stack<typename Container::value_type, Container>; // C++17 |
| 66 | |
| 67 | template<class Container, class Allocator> |
| 68 | stack(Container, Allocator) -> stack<typename Container::value_type, Container>; // C++17 |
| 69 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 70 | template <class T, class Container> |
| 71 | bool operator==(const stack<T, Container>& x, const stack<T, Container>& y); |
| 72 | template <class T, class Container> |
| 73 | bool operator< (const stack<T, Container>& x, const stack<T, Container>& y); |
| 74 | template <class T, class Container> |
| 75 | bool operator!=(const stack<T, Container>& x, const stack<T, Container>& y); |
| 76 | template <class T, class Container> |
| 77 | bool operator> (const stack<T, Container>& x, const stack<T, Container>& y); |
| 78 | template <class T, class Container> |
| 79 | bool operator>=(const stack<T, Container>& x, const stack<T, Container>& y); |
| 80 | template <class T, class Container> |
| 81 | bool operator<=(const stack<T, Container>& x, const stack<T, Container>& y); |
| 82 | |
| 83 | template <class T, class Container> |
Howard Hinnant | 58cd823 | 2011-06-04 22:09:19 +0000 | [diff] [blame] | 84 | void swap(stack<T, Container>& x, stack<T, Container>& y) |
| 85 | noexcept(noexcept(x.swap(y))); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 86 | |
| 87 | } // std |
| 88 | |
| 89 | */ |
| 90 | |
| 91 | #include <__config> |
| 92 | #include <deque> |
| 93 | |
Howard Hinnant | 08e1747 | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 94 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 95 | #pragma GCC system_header |
Howard Hinnant | 08e1747 | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 96 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 97 | |
| 98 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 99 | |
Eric Fiselier | c3589a8 | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 100 | template <class _Tp, class _Container = deque<_Tp> > class _LIBCPP_TEMPLATE_VIS stack; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 101 | |
| 102 | template <class _Tp, class _Container> |
Howard Hinnant | 33be35e | 2012-09-14 00:39:16 +0000 | [diff] [blame] | 103 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 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 | 33be35e | 2012-09-14 00:39:16 +0000 | [diff] [blame] | 108 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 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 | a46f5ce | 2015-02-18 17:51:56 +0000 | [diff] [blame] | 112 | template <class _Tp, class _Container /*= deque<_Tp>*/> |
Eric Fiselier | c3589a8 | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 113 | class _LIBCPP_TEMPLATE_VIS stack |
Howard Hinnant | bc8d3f9 | 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 | ed77ffb | 2016-03-14 17:58:11 +0000 | [diff] [blame] | 121 | static_assert((is_same<_Tp, value_type>::value), "" ); |
| 122 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 123 | protected: |
| 124 | container_type c; |
| 125 | |
| 126 | public: |
Howard Hinnant | 8d7a955 | 2010-09-23 17:31:07 +0000 | [diff] [blame] | 127 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 58cd823 | 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 | 7162dce | 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 | 58cd823 | 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 | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 143 | : c(_VSTD::move(__q.c)) {} |
Howard Hinnant | 58cd823 | 2011-06-04 22:09:19 +0000 | [diff] [blame] | 144 | |
| 145 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 58cd823 | 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 | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 148 | {c = _VSTD::move(__q.c); return *this;} |
Eric Fiselier | 7162dce | 2017-04-18 21:16:26 +0000 | [diff] [blame] | 149 | |
| 150 | _LIBCPP_INLINE_VISIBILITY |
| 151 | explicit stack(container_type&& __c) : c(_VSTD::move(__c)) {} |
| 152 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | 58cd823 | 2011-06-04 22:09:19 +0000 | [diff] [blame] | 153 | |
Howard Hinnant | 8d7a955 | 2010-09-23 17:31:07 +0000 | [diff] [blame] | 154 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 155 | explicit stack(const container_type& __c) : c(__c) {} |
Eric Fiselier | 7162dce | 2017-04-18 21:16:26 +0000 | [diff] [blame] | 156 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 157 | template <class _Alloc> |
Howard Hinnant | 8d7a955 | 2010-09-23 17:31:07 +0000 | [diff] [blame] | 158 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 159 | explicit stack(const _Alloc& __a, |
| 160 | typename enable_if<uses_allocator<container_type, |
| 161 | _Alloc>::value>::type* = 0) |
| 162 | : c(__a) {} |
| 163 | template <class _Alloc> |
Howard Hinnant | 8d7a955 | 2010-09-23 17:31:07 +0000 | [diff] [blame] | 164 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 165 | stack(const container_type& __c, const _Alloc& __a, |
| 166 | typename enable_if<uses_allocator<container_type, |
| 167 | _Alloc>::value>::type* = 0) |
| 168 | : c(__c, __a) {} |
| 169 | template <class _Alloc> |
Howard Hinnant | 8d7a955 | 2010-09-23 17:31:07 +0000 | [diff] [blame] | 170 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 171 | stack(const stack& __s, const _Alloc& __a, |
| 172 | typename enable_if<uses_allocator<container_type, |
| 173 | _Alloc>::value>::type* = 0) |
| 174 | : c(__s.c, __a) {} |
Eric Fiselier | 7162dce | 2017-04-18 21:16:26 +0000 | [diff] [blame] | 175 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 176 | template <class _Alloc> |
Howard Hinnant | 8d7a955 | 2010-09-23 17:31:07 +0000 | [diff] [blame] | 177 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 178 | stack(container_type&& __c, const _Alloc& __a, |
| 179 | typename enable_if<uses_allocator<container_type, |
| 180 | _Alloc>::value>::type* = 0) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 181 | : c(_VSTD::move(__c), __a) {} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 182 | template <class _Alloc> |
Howard Hinnant | 8d7a955 | 2010-09-23 17:31:07 +0000 | [diff] [blame] | 183 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 184 | stack(stack&& __s, const _Alloc& __a, |
| 185 | typename enable_if<uses_allocator<container_type, |
| 186 | _Alloc>::value>::type* = 0) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 187 | : c(_VSTD::move(__s.c), __a) {} |
Eric Fiselier | 7162dce | 2017-04-18 21:16:26 +0000 | [diff] [blame] | 188 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 189 | |
Marshall Clow | 88626bf | 2017-11-15 05:51:26 +0000 | [diff] [blame] | 190 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 191 | bool empty() const {return c.empty();} |
Howard Hinnant | 8d7a955 | 2010-09-23 17:31:07 +0000 | [diff] [blame] | 192 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 193 | size_type size() const {return c.size();} |
Howard Hinnant | 8d7a955 | 2010-09-23 17:31:07 +0000 | [diff] [blame] | 194 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 195 | reference top() {return c.back();} |
Howard Hinnant | 8d7a955 | 2010-09-23 17:31:07 +0000 | [diff] [blame] | 196 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 197 | const_reference top() const {return c.back();} |
| 198 | |
Howard Hinnant | 8d7a955 | 2010-09-23 17:31:07 +0000 | [diff] [blame] | 199 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 200 | void push(const value_type& __v) {c.push_back(__v);} |
Eric Fiselier | 7162dce | 2017-04-18 21:16:26 +0000 | [diff] [blame] | 201 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | 8d7a955 | 2010-09-23 17:31:07 +0000 | [diff] [blame] | 202 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 203 | void push(value_type&& __v) {c.push_back(_VSTD::move(__v));} |
Eric Fiselier | 7162dce | 2017-04-18 21:16:26 +0000 | [diff] [blame] | 204 | |
Howard Hinnant | 8d7a955 | 2010-09-23 17:31:07 +0000 | [diff] [blame] | 205 | template <class... _Args> |
| 206 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 4e42dc9 | 2017-01-24 23:09:12 +0000 | [diff] [blame] | 207 | #if _LIBCPP_STD_VER > 14 |
Marshall Clow | cc70488 | 2018-01-24 22:42:25 +0000 | [diff] [blame] | 208 | decltype(auto) emplace(_Args&&... __args) |
Eric Fiselier | 3816ef9 | 2016-07-21 03:20:17 +0000 | [diff] [blame] | 209 | { return c.emplace_back(_VSTD::forward<_Args>(__args)...);} |
Marshall Clow | 4e42dc9 | 2017-01-24 23:09:12 +0000 | [diff] [blame] | 210 | #else |
| 211 | void emplace(_Args&&... __args) |
| 212 | { c.emplace_back(_VSTD::forward<_Args>(__args)...);} |
| 213 | #endif |
Eric Fiselier | 7162dce | 2017-04-18 21:16:26 +0000 | [diff] [blame] | 214 | #endif // _LIBCPP_CXX03_LANG |
| 215 | |
Howard Hinnant | 8d7a955 | 2010-09-23 17:31:07 +0000 | [diff] [blame] | 216 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 217 | void pop() {c.pop_back();} |
| 218 | |
Howard Hinnant | 8d7a955 | 2010-09-23 17:31:07 +0000 | [diff] [blame] | 219 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 220 | void swap(stack& __s) |
Howard Hinnant | 58cd823 | 2011-06-04 22:09:19 +0000 | [diff] [blame] | 221 | _NOEXCEPT_(__is_nothrow_swappable<container_type>::value) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 222 | { |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 223 | using _VSTD::swap; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 224 | swap(c, __s.c); |
| 225 | } |
| 226 | |
| 227 | template <class T1, class _C1> |
| 228 | friend |
| 229 | bool |
| 230 | operator==(const stack<T1, _C1>& __x, const stack<T1, _C1>& __y); |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 231 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 232 | template <class T1, class _C1> |
| 233 | friend |
| 234 | bool |
| 235 | operator< (const stack<T1, _C1>& __x, const stack<T1, _C1>& __y); |
| 236 | }; |
| 237 | |
Marshall Clow | 0e5d707 | 2018-05-22 01:57:53 +0000 | [diff] [blame] | 238 | #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES |
| 239 | template<class _Container, |
| 240 | class = typename enable_if<!__is_allocator<_Container>::value, nullptr_t>::type |
| 241 | > |
| 242 | stack(_Container) |
| 243 | -> stack<typename _Container::value_type, _Container>; |
| 244 | |
| 245 | template<class _Container, |
| 246 | class _Alloc, |
| 247 | class = typename enable_if<!__is_allocator<_Container>::value, nullptr_t>::type, |
| 248 | class = typename enable_if< __is_allocator<_Alloc>::value, nullptr_t>::type |
| 249 | > |
| 250 | stack(_Container, _Alloc) |
| 251 | -> stack<typename _Container::value_type, _Container>; |
| 252 | #endif |
| 253 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 254 | template <class _Tp, class _Container> |
Howard Hinnant | 8d7a955 | 2010-09-23 17:31:07 +0000 | [diff] [blame] | 255 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 256 | bool |
| 257 | operator==(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y) |
| 258 | { |
| 259 | return __x.c == __y.c; |
| 260 | } |
| 261 | |
| 262 | template <class _Tp, class _Container> |
Howard Hinnant | 8d7a955 | 2010-09-23 17:31:07 +0000 | [diff] [blame] | 263 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 264 | bool |
| 265 | operator< (const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y) |
| 266 | { |
| 267 | return __x.c < __y.c; |
| 268 | } |
| 269 | |
| 270 | template <class _Tp, class _Container> |
Howard Hinnant | 8d7a955 | 2010-09-23 17:31:07 +0000 | [diff] [blame] | 271 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 272 | bool |
| 273 | operator!=(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y) |
| 274 | { |
| 275 | return !(__x == __y); |
| 276 | } |
| 277 | |
| 278 | template <class _Tp, class _Container> |
Howard Hinnant | 8d7a955 | 2010-09-23 17:31:07 +0000 | [diff] [blame] | 279 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 280 | bool |
| 281 | operator> (const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y) |
| 282 | { |
| 283 | return __y < __x; |
| 284 | } |
| 285 | |
| 286 | template <class _Tp, class _Container> |
Howard Hinnant | 8d7a955 | 2010-09-23 17:31:07 +0000 | [diff] [blame] | 287 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 288 | bool |
| 289 | operator>=(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y) |
| 290 | { |
| 291 | return !(__x < __y); |
| 292 | } |
| 293 | |
| 294 | template <class _Tp, class _Container> |
Howard Hinnant | 8d7a955 | 2010-09-23 17:31:07 +0000 | [diff] [blame] | 295 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 296 | bool |
| 297 | operator<=(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y) |
| 298 | { |
| 299 | return !(__y < __x); |
| 300 | } |
| 301 | |
| 302 | template <class _Tp, class _Container> |
Howard Hinnant | 8d7a955 | 2010-09-23 17:31:07 +0000 | [diff] [blame] | 303 | inline _LIBCPP_INLINE_VISIBILITY |
Eric Fiselier | 8f1e73d | 2016-04-21 23:38:59 +0000 | [diff] [blame] | 304 | typename enable_if< |
| 305 | __is_swappable<_Container>::value, |
| 306 | void |
| 307 | >::type |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 308 | swap(stack<_Tp, _Container>& __x, stack<_Tp, _Container>& __y) |
Howard Hinnant | 58cd823 | 2011-06-04 22:09:19 +0000 | [diff] [blame] | 309 | _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 310 | { |
| 311 | __x.swap(__y); |
| 312 | } |
| 313 | |
| 314 | template <class _Tp, class _Container, class _Alloc> |
Eric Fiselier | c3589a8 | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 315 | struct _LIBCPP_TEMPLATE_VIS uses_allocator<stack<_Tp, _Container>, _Alloc> |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 316 | : public uses_allocator<_Container, _Alloc> |
| 317 | { |
| 318 | }; |
| 319 | |
| 320 | _LIBCPP_END_NAMESPACE_STD |
| 321 | |
| 322 | #endif // _LIBCPP_STACK |