| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 1 | // -*- C++ -*- | 
|  | 2 | //===---------------------------- stack -----------------------------------===// | 
|  | 3 | // | 
| Howard Hinnant | f5256e1 | 2010-05-11 21:36:01 | [diff] [blame] | 4 | // The LLVM Compiler Infrastructure | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 5 | // | 
| Howard Hinnant | b64f8b0 | 2010-11-16 22:09:02 | [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 | [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 | [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 | [diff] [blame] | 43 | explicit stack(const container_type& c); | 
|  | 44 | explicit stack(container_type&& c); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [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 | [diff] [blame] | 48 | template <class Alloc> stack(const stack& c, const Alloc& a); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [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 | [diff] [blame] | 58 | template <class... Args> reference emplace(Args&&... args); // reference in C++17 | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 59 | void pop(); | 
|  | 60 |  | 
| Eric Fiselier | 8f1e73d | 2016-04-21 23:38:59 | [diff] [blame] | 61 | void swap(stack& c) noexcept(is_nothrow_swappable_v<Container>) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 62 | }; | 
|  | 63 |  | 
|  | 64 | template <class T, class Container> | 
|  | 65 | bool operator==(const stack<T, Container>& x, const stack<T, Container>& y); | 
|  | 66 | template <class T, class Container> | 
|  | 67 | bool operator< (const stack<T, Container>& x, const stack<T, Container>& y); | 
|  | 68 | template <class T, class Container> | 
|  | 69 | bool operator!=(const stack<T, Container>& x, const stack<T, Container>& y); | 
|  | 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 |  | 
|  | 77 | template <class T, class Container> | 
| Howard Hinnant | 58cd823 | 2011-06-04 22:09:19 | [diff] [blame] | 78 | void swap(stack<T, Container>& x, stack<T, Container>& y) | 
|  | 79 | noexcept(noexcept(x.swap(y))); | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 80 |  | 
|  | 81 | } // std | 
|  | 82 |  | 
|  | 83 | */ | 
|  | 84 |  | 
|  | 85 | #include <__config> | 
|  | 86 | #include <deque> | 
|  | 87 |  | 
| Howard Hinnant | 08e1747 | 2011-10-17 20:05:10 | [diff] [blame] | 88 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 89 | #pragma GCC system_header | 
| Howard Hinnant | 08e1747 | 2011-10-17 20:05:10 | [diff] [blame] | 90 | #endif | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 91 |  | 
|  | 92 | _LIBCPP_BEGIN_NAMESPACE_STD | 
|  | 93 |  | 
| Eric Fiselier | c3589a8 | 2017-01-04 23:56:00 | [diff] [blame] | 94 | template <class _Tp, class _Container = deque<_Tp> > class _LIBCPP_TEMPLATE_VIS stack; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 95 |  | 
|  | 96 | template <class _Tp, class _Container> | 
| Howard Hinnant | 33be35e | 2012-09-14 00:39:16 | [diff] [blame] | 97 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 98 | bool | 
|  | 99 | operator==(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y); | 
|  | 100 |  | 
|  | 101 | template <class _Tp, class _Container> | 
| Howard Hinnant | 33be35e | 2012-09-14 00:39:16 | [diff] [blame] | 102 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 103 | bool | 
|  | 104 | operator< (const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y); | 
|  | 105 |  | 
| Marshall Clow | a46f5ce | 2015-02-18 17:51:56 | [diff] [blame] | 106 | template <class _Tp, class _Container /*= deque<_Tp>*/> | 
| Eric Fiselier | c3589a8 | 2017-01-04 23:56:00 | [diff] [blame] | 107 | class _LIBCPP_TEMPLATE_VIS stack | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 108 | { | 
|  | 109 | public: | 
|  | 110 | typedef _Container container_type; | 
|  | 111 | typedef typename container_type::value_type value_type; | 
|  | 112 | typedef typename container_type::reference reference; | 
|  | 113 | typedef typename container_type::const_reference const_reference; | 
|  | 114 | typedef typename container_type::size_type size_type; | 
| Marshall Clow | ed77ffb | 2016-03-14 17:58:11 | [diff] [blame] | 115 | static_assert((is_same<_Tp, value_type>::value), "" ); | 
|  | 116 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 117 | protected: | 
|  | 118 | container_type c; | 
|  | 119 |  | 
|  | 120 | public: | 
| Howard Hinnant | 8d7a955 | 2010-09-23 17:31:07 | [diff] [blame] | 121 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 58cd823 | 2011-06-04 22:09:19 | [diff] [blame] | 122 | stack() | 
|  | 123 | _NOEXCEPT_(is_nothrow_default_constructible<container_type>::value) | 
|  | 124 | : c() {} | 
|  | 125 |  | 
|  | 126 | _LIBCPP_INLINE_VISIBILITY | 
|  | 127 | stack(const stack& __q) : c(__q.c) {} | 
|  | 128 |  | 
| Eric Fiselier | 7162dce | 2017-04-18 21:16:26 | [diff] [blame] | 129 | _LIBCPP_INLINE_VISIBILITY | 
|  | 130 | stack& operator=(const stack& __q) {c = __q.c; return *this;} | 
|  | 131 |  | 
|  | 132 |  | 
|  | 133 | #ifndef _LIBCPP_CXX03_LANG | 
| Howard Hinnant | 58cd823 | 2011-06-04 22:09:19 | [diff] [blame] | 134 | _LIBCPP_INLINE_VISIBILITY | 
|  | 135 | stack(stack&& __q) | 
|  | 136 | _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 137 | : c(_VSTD::move(__q.c)) {} | 
| Howard Hinnant | 58cd823 | 2011-06-04 22:09:19 | [diff] [blame] | 138 |  | 
|  | 139 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 58cd823 | 2011-06-04 22:09:19 | [diff] [blame] | 140 | stack& operator=(stack&& __q) | 
|  | 141 | _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 142 | {c = _VSTD::move(__q.c); return *this;} | 
| Eric Fiselier | 7162dce | 2017-04-18 21:16:26 | [diff] [blame] | 143 |  | 
|  | 144 | _LIBCPP_INLINE_VISIBILITY | 
|  | 145 | explicit stack(container_type&& __c) : c(_VSTD::move(__c)) {} | 
|  | 146 | #endif // _LIBCPP_CXX03_LANG | 
| Howard Hinnant | 58cd823 | 2011-06-04 22:09:19 | [diff] [blame] | 147 |  | 
| Howard Hinnant | 8d7a955 | 2010-09-23 17:31:07 | [diff] [blame] | 148 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 149 | explicit stack(const container_type& __c) : c(__c) {} | 
| Eric Fiselier | 7162dce | 2017-04-18 21:16:26 | [diff] [blame] | 150 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 151 | template <class _Alloc> | 
| Howard Hinnant | 8d7a955 | 2010-09-23 17:31:07 | [diff] [blame] | 152 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 153 | explicit stack(const _Alloc& __a, | 
|  | 154 | typename enable_if<uses_allocator<container_type, | 
|  | 155 | _Alloc>::value>::type* = 0) | 
|  | 156 | : c(__a) {} | 
|  | 157 | template <class _Alloc> | 
| Howard Hinnant | 8d7a955 | 2010-09-23 17:31:07 | [diff] [blame] | 158 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 159 | stack(const container_type& __c, const _Alloc& __a, | 
|  | 160 | typename enable_if<uses_allocator<container_type, | 
|  | 161 | _Alloc>::value>::type* = 0) | 
|  | 162 | : c(__c, __a) {} | 
|  | 163 | template <class _Alloc> | 
| Howard Hinnant | 8d7a955 | 2010-09-23 17:31:07 | [diff] [blame] | 164 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 165 | stack(const stack& __s, const _Alloc& __a, | 
|  | 166 | typename enable_if<uses_allocator<container_type, | 
|  | 167 | _Alloc>::value>::type* = 0) | 
|  | 168 | : c(__s.c, __a) {} | 
| Eric Fiselier | 7162dce | 2017-04-18 21:16:26 | [diff] [blame] | 169 | #ifndef _LIBCPP_CXX03_LANG | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 170 | template <class _Alloc> | 
| Howard Hinnant | 8d7a955 | 2010-09-23 17:31:07 | [diff] [blame] | 171 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 172 | stack(container_type&& __c, const _Alloc& __a, | 
|  | 173 | typename enable_if<uses_allocator<container_type, | 
|  | 174 | _Alloc>::value>::type* = 0) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 175 | : c(_VSTD::move(__c), __a) {} | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 176 | template <class _Alloc> | 
| Howard Hinnant | 8d7a955 | 2010-09-23 17:31:07 | [diff] [blame] | 177 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 178 | stack(stack&& __s, 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 | [diff] [blame] | 181 | : c(_VSTD::move(__s.c), __a) {} | 
| Eric Fiselier | 7162dce | 2017-04-18 21:16:26 | [diff] [blame] | 182 | #endif // _LIBCPP_CXX03_LANG | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 183 |  | 
| Marshall Clow | 88626bf | 2017-11-15 05:51:26 | [diff] [blame] | 184 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 185 | bool empty() const {return c.empty();} | 
| Howard Hinnant | 8d7a955 | 2010-09-23 17:31:07 | [diff] [blame] | 186 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 187 | size_type size() const {return c.size();} | 
| Howard Hinnant | 8d7a955 | 2010-09-23 17:31:07 | [diff] [blame] | 188 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 189 | reference top() {return c.back();} | 
| Howard Hinnant | 8d7a955 | 2010-09-23 17:31:07 | [diff] [blame] | 190 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 191 | const_reference top() const {return c.back();} | 
|  | 192 |  | 
| Howard Hinnant | 8d7a955 | 2010-09-23 17:31:07 | [diff] [blame] | 193 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 194 | void push(const value_type& __v) {c.push_back(__v);} | 
| Eric Fiselier | 7162dce | 2017-04-18 21:16:26 | [diff] [blame] | 195 | #ifndef _LIBCPP_CXX03_LANG | 
| Howard Hinnant | 8d7a955 | 2010-09-23 17:31:07 | [diff] [blame] | 196 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 197 | void push(value_type&& __v) {c.push_back(_VSTD::move(__v));} | 
| Eric Fiselier | 7162dce | 2017-04-18 21:16:26 | [diff] [blame] | 198 |  | 
| Howard Hinnant | 8d7a955 | 2010-09-23 17:31:07 | [diff] [blame] | 199 | template <class... _Args> | 
|  | 200 | _LIBCPP_INLINE_VISIBILITY | 
| Marshall Clow | 4e42dc9 | 2017-01-24 23:09:12 | [diff] [blame] | 201 | #if _LIBCPP_STD_VER > 14 | 
| Eric Fiselier | 3816ef9 | 2016-07-21 03:20:17 | [diff] [blame] | 202 | reference emplace(_Args&&... __args) | 
|  | 203 | { return c.emplace_back(_VSTD::forward<_Args>(__args)...);} | 
| Marshall Clow | 4e42dc9 | 2017-01-24 23:09:12 | [diff] [blame] | 204 | #else | 
|  | 205 | void emplace(_Args&&... __args) | 
|  | 206 | { c.emplace_back(_VSTD::forward<_Args>(__args)...);} | 
|  | 207 | #endif | 
| Eric Fiselier | 7162dce | 2017-04-18 21:16:26 | [diff] [blame] | 208 | #endif // _LIBCPP_CXX03_LANG | 
|  | 209 |  | 
| Howard Hinnant | 8d7a955 | 2010-09-23 17:31:07 | [diff] [blame] | 210 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 211 | void pop() {c.pop_back();} | 
|  | 212 |  | 
| Howard Hinnant | 8d7a955 | 2010-09-23 17:31:07 | [diff] [blame] | 213 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 214 | void swap(stack& __s) | 
| Howard Hinnant | 58cd823 | 2011-06-04 22:09:19 | [diff] [blame] | 215 | _NOEXCEPT_(__is_nothrow_swappable<container_type>::value) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 216 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 217 | using _VSTD::swap; | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 218 | swap(c, __s.c); | 
|  | 219 | } | 
|  | 220 |  | 
|  | 221 | template <class T1, class _C1> | 
|  | 222 | friend | 
|  | 223 | bool | 
|  | 224 | operator==(const stack<T1, _C1>& __x, const stack<T1, _C1>& __y); | 
| Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 | [diff] [blame] | 225 |  | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 226 | template <class T1, class _C1> | 
|  | 227 | friend | 
|  | 228 | bool | 
|  | 229 | operator< (const stack<T1, _C1>& __x, const stack<T1, _C1>& __y); | 
|  | 230 | }; | 
|  | 231 |  | 
|  | 232 | template <class _Tp, class _Container> | 
| Howard Hinnant | 8d7a955 | 2010-09-23 17:31:07 | [diff] [blame] | 233 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 234 | bool | 
|  | 235 | operator==(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y) | 
|  | 236 | { | 
|  | 237 | return __x.c == __y.c; | 
|  | 238 | } | 
|  | 239 |  | 
|  | 240 | template <class _Tp, class _Container> | 
| Howard Hinnant | 8d7a955 | 2010-09-23 17:31:07 | [diff] [blame] | 241 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 242 | bool | 
|  | 243 | operator< (const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y) | 
|  | 244 | { | 
|  | 245 | return __x.c < __y.c; | 
|  | 246 | } | 
|  | 247 |  | 
|  | 248 | template <class _Tp, class _Container> | 
| Howard Hinnant | 8d7a955 | 2010-09-23 17:31:07 | [diff] [blame] | 249 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 250 | bool | 
|  | 251 | operator!=(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y) | 
|  | 252 | { | 
|  | 253 | return !(__x == __y); | 
|  | 254 | } | 
|  | 255 |  | 
|  | 256 | template <class _Tp, class _Container> | 
| Howard Hinnant | 8d7a955 | 2010-09-23 17:31:07 | [diff] [blame] | 257 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 258 | bool | 
|  | 259 | operator> (const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y) | 
|  | 260 | { | 
|  | 261 | return __y < __x; | 
|  | 262 | } | 
|  | 263 |  | 
|  | 264 | template <class _Tp, class _Container> | 
| Howard Hinnant | 8d7a955 | 2010-09-23 17:31:07 | [diff] [blame] | 265 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 266 | bool | 
|  | 267 | operator>=(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y) | 
|  | 268 | { | 
|  | 269 | return !(__x < __y); | 
|  | 270 | } | 
|  | 271 |  | 
|  | 272 | template <class _Tp, class _Container> | 
| Howard Hinnant | 8d7a955 | 2010-09-23 17:31:07 | [diff] [blame] | 273 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 274 | bool | 
|  | 275 | operator<=(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y) | 
|  | 276 | { | 
|  | 277 | return !(__y < __x); | 
|  | 278 | } | 
|  | 279 |  | 
|  | 280 | template <class _Tp, class _Container> | 
| Howard Hinnant | 8d7a955 | 2010-09-23 17:31:07 | [diff] [blame] | 281 | inline _LIBCPP_INLINE_VISIBILITY | 
| Eric Fiselier | 8f1e73d | 2016-04-21 23:38:59 | [diff] [blame] | 282 | typename enable_if< | 
|  | 283 | __is_swappable<_Container>::value, | 
|  | 284 | void | 
|  | 285 | >::type | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 286 | swap(stack<_Tp, _Container>& __x, stack<_Tp, _Container>& __y) | 
| Howard Hinnant | 58cd823 | 2011-06-04 22:09:19 | [diff] [blame] | 287 | _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 288 | { | 
|  | 289 | __x.swap(__y); | 
|  | 290 | } | 
|  | 291 |  | 
|  | 292 | template <class _Tp, class _Container, class _Alloc> | 
| Eric Fiselier | c3589a8 | 2017-01-04 23:56:00 | [diff] [blame] | 293 | struct _LIBCPP_TEMPLATE_VIS uses_allocator<stack<_Tp, _Container>, _Alloc> | 
| Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 | [diff] [blame] | 294 | : public uses_allocator<_Container, _Alloc> | 
|  | 295 | { | 
|  | 296 | }; | 
|  | 297 |  | 
|  | 298 | _LIBCPP_END_NAMESPACE_STD | 
|  | 299 |  | 
|  | 300 | #endif // _LIBCPP_STACK |