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