xref: /llvm-project-15.0.7/libcxx/include/stack (revision de4a57cb)
13e519524SHoward Hinnant// -*- C++ -*-
2eb8650a7SLouis Dionne//===----------------------------------------------------------------------===//
33e519524SHoward Hinnant//
457b08b09SChandler Carruth// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
557b08b09SChandler Carruth// See https://llvm.org/LICENSE.txt for license information.
657b08b09SChandler Carruth// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
73e519524SHoward Hinnant//
83e519524SHoward Hinnant//===----------------------------------------------------------------------===//
93e519524SHoward Hinnant
103e519524SHoward Hinnant#ifndef _LIBCPP_STACK
113e519524SHoward Hinnant#define _LIBCPP_STACK
123e519524SHoward Hinnant
133e519524SHoward Hinnant/*
143e519524SHoward Hinnant    stack synopsis
153e519524SHoward Hinnant
163e519524SHoward Hinnantnamespace std
173e519524SHoward Hinnant{
183e519524SHoward Hinnant
193e519524SHoward Hinnanttemplate <class T, class Container = deque<T>>
203e519524SHoward Hinnantclass stack
213e519524SHoward Hinnant{
223e519524SHoward Hinnantpublic:
233e519524SHoward Hinnant    typedef Container                                container_type;
243e519524SHoward Hinnant    typedef typename container_type::value_type      value_type;
253e519524SHoward Hinnant    typedef typename container_type::reference       reference;
263e519524SHoward Hinnant    typedef typename container_type::const_reference const_reference;
273e519524SHoward Hinnant    typedef typename container_type::size_type       size_type;
283e519524SHoward Hinnant
293e519524SHoward Hinnantprotected:
303e519524SHoward Hinnant    container_type c;
313e519524SHoward Hinnant
323e519524SHoward Hinnantpublic:
33bd0c1600SHoward Hinnant    stack() = default;
34bd0c1600SHoward Hinnant    ~stack() = default;
35bd0c1600SHoward Hinnant
36bd0c1600SHoward Hinnant    stack(const stack& q) = default;
37bd0c1600SHoward Hinnant    stack(stack&& q) = default;
38bd0c1600SHoward Hinnant
39bd0c1600SHoward Hinnant    stack& operator=(const stack& q) = default;
40bd0c1600SHoward Hinnant    stack& operator=(stack&& q) = default;
41bd0c1600SHoward Hinnant
423e519524SHoward Hinnant    explicit stack(const container_type& c);
433e519524SHoward Hinnant    explicit stack(container_type&& c);
44f3aed369SNikolas Klauser    template <class InputIterator> stack(InputIterator first, InputIterator last); // since C++23
453e519524SHoward Hinnant    template <class Alloc> explicit stack(const Alloc& a);
463e519524SHoward Hinnant    template <class Alloc> stack(const container_type& c, const Alloc& a);
473e519524SHoward Hinnant    template <class Alloc> stack(container_type&& c, const Alloc& a);
48bd0c1600SHoward Hinnant    template <class Alloc> stack(const stack& c, const Alloc& a);
493e519524SHoward Hinnant    template <class Alloc> stack(stack&& c, const Alloc& a);
50f3aed369SNikolas Klauser    template<class InputIterator, class Alloc>
51f3aed369SNikolas Klauser    stack(InputIterator first, InputIterator last, const Alloc&); // since C++23
523e519524SHoward Hinnant
533e519524SHoward Hinnant    bool empty() const;
543e519524SHoward Hinnant    size_type size() const;
553e519524SHoward Hinnant    reference top();
563e519524SHoward Hinnant    const_reference top() const;
573e519524SHoward Hinnant
583e519524SHoward Hinnant    void push(const value_type& x);
593e519524SHoward Hinnant    void push(value_type&& x);
6063b560beSMarshall Clow    template <class... Args> reference emplace(Args&&... args); // reference in C++17
613e519524SHoward Hinnant    void pop();
623e519524SHoward Hinnant
63f07dd8d0SEric Fiselier    void swap(stack& c) noexcept(is_nothrow_swappable_v<Container>)
643e519524SHoward Hinnant};
653e519524SHoward Hinnant
665b8b8b5dSMarshall Clowtemplate<class Container>
675b8b8b5dSMarshall Clow  stack(Container) -> stack<typename Container::value_type, Container>;  // C++17
685b8b8b5dSMarshall Clow
69f3aed369SNikolas Klausertemplate<class InputIterator>
70f3aed369SNikolas Klauser  stack(InputIterator, InputIterator) -> stack<iter-value-type<InputIterator>>; // since C++23
71f3aed369SNikolas Klauser
725b8b8b5dSMarshall Clowtemplate<class Container, class Allocator>
735b8b8b5dSMarshall Clow  stack(Container, Allocator) -> stack<typename Container::value_type, Container>; // C++17
745b8b8b5dSMarshall Clow
75f3aed369SNikolas Klausertemplate<class InputIterator, class Allocator>
76f3aed369SNikolas Klauser  stack(InputIterator, InputIterator, Allocator)
77f3aed369SNikolas Klauser    -> stack<iter-value-type<InputIterator>,
78f3aed369SNikolas Klauser             deque<iter-value-type<InputIterator>, Allocator>>; // since C++23
79f3aed369SNikolas Klauser
803e519524SHoward Hinnanttemplate <class T, class Container>
813e519524SHoward Hinnant  bool operator==(const stack<T, Container>& x, const stack<T, Container>& y);
823e519524SHoward Hinnanttemplate <class T, class Container>
833e519524SHoward Hinnant  bool operator< (const stack<T, Container>& x, const stack<T, Container>& y);
843e519524SHoward Hinnanttemplate <class T, class Container>
853e519524SHoward Hinnant  bool operator!=(const stack<T, Container>& x, const stack<T, Container>& y);
863e519524SHoward Hinnanttemplate <class T, class Container>
873e519524SHoward Hinnant  bool operator> (const stack<T, Container>& x, const stack<T, Container>& y);
883e519524SHoward Hinnanttemplate <class T, class Container>
893e519524SHoward Hinnant  bool operator>=(const stack<T, Container>& x, const stack<T, Container>& y);
903e519524SHoward Hinnanttemplate <class T, class Container>
913e519524SHoward Hinnant  bool operator<=(const stack<T, Container>& x, const stack<T, Container>& y);
923e519524SHoward Hinnant
933e519524SHoward Hinnanttemplate <class T, class Container>
94bd0c1600SHoward Hinnant  void swap(stack<T, Container>& x, stack<T, Container>& y)
95bd0c1600SHoward Hinnant  noexcept(noexcept(x.swap(y)));
963e519524SHoward Hinnant
973e519524SHoward Hinnant}  // std
983e519524SHoward Hinnant
993e519524SHoward Hinnant*/
1003e519524SHoward Hinnant
101385cc25aSLouis Dionne#include <__assert> // all public C++ headers provide the assertion handler
1023e519524SHoward Hinnant#include <__config>
103f3aed369SNikolas Klauser#include <__iterator/iterator_traits.h>
104050b064fSChristopher Di Bella#include <__memory/uses_allocator.h>
1056adbc83eSChristopher Di Bella#include <__utility/forward.h>
1063e519524SHoward Hinnant#include <deque>
107f3aed369SNikolas Klauser#include <type_traits>
108bd6e6846SMark de Wever#include <version>
1093e519524SHoward Hinnant
110*de4a57cbSLouis Dionne#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
111*de4a57cbSLouis Dionne#  include <functional>
112*de4a57cbSLouis Dionne#endif
113*de4a57cbSLouis Dionne
114db1978b6SNikolas Klauser// standard-mandated includes
115db1978b6SNikolas Klauser#include <compare>
116db1978b6SNikolas Klauser#include <initializer_list>
117db1978b6SNikolas Klauser
118073458b1SHoward Hinnant#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1193e519524SHoward Hinnant#  pragma GCC system_header
120073458b1SHoward Hinnant#endif
1213e519524SHoward Hinnant
1223e519524SHoward Hinnant_LIBCPP_BEGIN_NAMESPACE_STD
1233e519524SHoward Hinnant
124e2f2d1edSEric Fiseliertemplate <class _Tp, class _Container = deque<_Tp> > class _LIBCPP_TEMPLATE_VIS stack;
1253e519524SHoward Hinnant
1263e519524SHoward Hinnanttemplate <class _Tp, class _Container>
127aeb85680SHoward Hinnant_LIBCPP_INLINE_VISIBILITY
1283e519524SHoward Hinnantbool
1293e519524SHoward Hinnantoperator==(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y);
1303e519524SHoward Hinnant
1313e519524SHoward Hinnanttemplate <class _Tp, class _Container>
132aeb85680SHoward Hinnant_LIBCPP_INLINE_VISIBILITY
1333e519524SHoward Hinnantbool
1343e519524SHoward Hinnantoperator< (const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y);
1353e519524SHoward Hinnant
1363afa22a3SMarshall Clowtemplate <class _Tp, class _Container /*= deque<_Tp>*/>
137e2f2d1edSEric Fiselierclass _LIBCPP_TEMPLATE_VIS stack
1383e519524SHoward Hinnant{
1393e519524SHoward Hinnantpublic:
1403e519524SHoward Hinnant    typedef _Container                               container_type;
1413e519524SHoward Hinnant    typedef typename container_type::value_type      value_type;
1423e519524SHoward Hinnant    typedef typename container_type::reference       reference;
1433e519524SHoward Hinnant    typedef typename container_type::const_reference const_reference;
1443e519524SHoward Hinnant    typedef typename container_type::size_type       size_type;
145c1fe2c43SMarshall Clow    static_assert((is_same<_Tp, value_type>::value), "" );
1463e519524SHoward Hinnant
1473e519524SHoward Hinnantprotected:
1483e519524SHoward Hinnant    container_type c;
1493e519524SHoward Hinnant
1503e519524SHoward Hinnantpublic:
151e0601335SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
152bd0c1600SHoward Hinnant    stack()
153bd0c1600SHoward Hinnant        _NOEXCEPT_(is_nothrow_default_constructible<container_type>::value)
154bd0c1600SHoward Hinnant        : c() {}
155bd0c1600SHoward Hinnant
156bd0c1600SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
157bd0c1600SHoward Hinnant    stack(const stack& __q) : c(__q.c) {}
158bd0c1600SHoward Hinnant
1597196ee31SEric Fiselier    _LIBCPP_INLINE_VISIBILITY
1607196ee31SEric Fiselier    stack& operator=(const stack& __q) {c = __q.c; return *this;}
1617196ee31SEric Fiselier
1627196ee31SEric Fiselier
1637196ee31SEric Fiselier#ifndef _LIBCPP_CXX03_LANG
164bd0c1600SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
165bd0c1600SHoward Hinnant    stack(stack&& __q)
166bd0c1600SHoward Hinnant        _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value)
167ce48a113SHoward Hinnant        : c(_VSTD::move(__q.c)) {}
168bd0c1600SHoward Hinnant
169bd0c1600SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
170bd0c1600SHoward Hinnant    stack& operator=(stack&& __q)
171bd0c1600SHoward Hinnant        _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value)
172ce48a113SHoward Hinnant        {c = _VSTD::move(__q.c); return *this;}
1737196ee31SEric Fiselier
1747196ee31SEric Fiselier    _LIBCPP_INLINE_VISIBILITY
1757196ee31SEric Fiselier    explicit stack(container_type&& __c) : c(_VSTD::move(__c)) {}
1767196ee31SEric Fiselier#endif // _LIBCPP_CXX03_LANG
177bd0c1600SHoward Hinnant
178e0601335SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
1793e519524SHoward Hinnant    explicit stack(const container_type& __c) : c(__c) {}
1807196ee31SEric Fiselier
1813e519524SHoward Hinnant    template <class _Alloc>
182e0601335SHoward Hinnant        _LIBCPP_INLINE_VISIBILITY
1833e519524SHoward Hinnant        explicit stack(const _Alloc& __a,
184b4e88d4dSLouis Dionne                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0)
1853e519524SHoward Hinnant            : c(__a) {}
1863e519524SHoward Hinnant    template <class _Alloc>
187e0601335SHoward Hinnant        _LIBCPP_INLINE_VISIBILITY
1883e519524SHoward Hinnant        stack(const container_type& __c, const _Alloc& __a,
189b4e88d4dSLouis Dionne              __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0)
1903e519524SHoward Hinnant            : c(__c, __a) {}
1913e519524SHoward Hinnant    template <class _Alloc>
192e0601335SHoward Hinnant        _LIBCPP_INLINE_VISIBILITY
1933e519524SHoward Hinnant        stack(const stack& __s, const _Alloc& __a,
194b4e88d4dSLouis Dionne              __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0)
1953e519524SHoward Hinnant            : c(__s.c, __a) {}
1967196ee31SEric Fiselier#ifndef _LIBCPP_CXX03_LANG
1973e519524SHoward Hinnant    template <class _Alloc>
198e0601335SHoward Hinnant        _LIBCPP_INLINE_VISIBILITY
1993e519524SHoward Hinnant        stack(container_type&& __c, const _Alloc& __a,
200b4e88d4dSLouis Dionne              __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0)
201ce48a113SHoward Hinnant            : c(_VSTD::move(__c), __a) {}
2023e519524SHoward Hinnant    template <class _Alloc>
203e0601335SHoward Hinnant        _LIBCPP_INLINE_VISIBILITY
2043e519524SHoward Hinnant        stack(stack&& __s, const _Alloc& __a,
205b4e88d4dSLouis Dionne              __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0)
206ce48a113SHoward Hinnant            : c(_VSTD::move(__s.c), __a) {}
2077196ee31SEric Fiselier#endif // _LIBCPP_CXX03_LANG
2083e519524SHoward Hinnant
209f3aed369SNikolas Klauser#if _LIBCPP_STD_VER > 20
210f3aed369SNikolas Klauser    template <class _InputIterator,
211f3aed369SNikolas Klauser              class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>>
212f3aed369SNikolas Klauser    _LIBCPP_HIDE_FROM_ABI
213f3aed369SNikolas Klauser    stack(_InputIterator __first, _InputIterator __last) : c(__first, __last) {}
214f3aed369SNikolas Klauser
215f3aed369SNikolas Klauser    template <class _InputIterator,
216f3aed369SNikolas Klauser              class _Alloc,
217f3aed369SNikolas Klauser              class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
218f3aed369SNikolas Klauser              class = __enable_if_t<uses_allocator<container_type, _Alloc>::value>>
219f3aed369SNikolas Klauser    _LIBCPP_HIDE_FROM_ABI
220f3aed369SNikolas Klauser    stack(_InputIterator __first, _InputIterator __last, const _Alloc& __alloc) : c(__first, __last, __alloc) {}
221f3aed369SNikolas Klauser#endif
222f3aed369SNikolas Klauser
22372c8fad4SMarshall Clow    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
2243e519524SHoward Hinnant    bool empty()     const      {return c.empty();}
225e0601335SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
2263e519524SHoward Hinnant    size_type size() const      {return c.size();}
227e0601335SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
2283e519524SHoward Hinnant    reference top()             {return c.back();}
229e0601335SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
2303e519524SHoward Hinnant    const_reference top() const {return c.back();}
2313e519524SHoward Hinnant
232e0601335SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
2333e519524SHoward Hinnant    void push(const value_type& __v) {c.push_back(__v);}
2347196ee31SEric Fiselier#ifndef _LIBCPP_CXX03_LANG
235e0601335SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
236ce48a113SHoward Hinnant    void push(value_type&& __v) {c.push_back(_VSTD::move(__v));}
2377196ee31SEric Fiselier
238e0601335SHoward Hinnant    template <class... _Args>
239e0601335SHoward Hinnant        _LIBCPP_INLINE_VISIBILITY
24063b560beSMarshall Clow#if _LIBCPP_STD_VER > 14
241e34f5ffeSMarshall Clow        decltype(auto) emplace(_Args&&... __args)
2420e411641SEric Fiselier        { return c.emplace_back(_VSTD::forward<_Args>(__args)...);}
24363b560beSMarshall Clow#else
24463b560beSMarshall Clow        void      emplace(_Args&&... __args)
24563b560beSMarshall Clow        {        c.emplace_back(_VSTD::forward<_Args>(__args)...);}
24663b560beSMarshall Clow#endif
2477196ee31SEric Fiselier#endif // _LIBCPP_CXX03_LANG
2487196ee31SEric Fiselier
249e0601335SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
2503e519524SHoward Hinnant    void pop() {c.pop_back();}
2513e519524SHoward Hinnant
252e0601335SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
2533e519524SHoward Hinnant    void swap(stack& __s)
254bd0c1600SHoward Hinnant        _NOEXCEPT_(__is_nothrow_swappable<container_type>::value)
2553e519524SHoward Hinnant    {
256ce48a113SHoward Hinnant        using _VSTD::swap;
2573e519524SHoward Hinnant        swap(c, __s.c);
2583e519524SHoward Hinnant    }
2593e519524SHoward Hinnant
2603e519524SHoward Hinnant    template <class T1, class _C1>
2613e519524SHoward Hinnant    friend
2623e519524SHoward Hinnant    bool
2633e519524SHoward Hinnant    operator==(const stack<T1, _C1>& __x, const stack<T1, _C1>& __y);
2643e519524SHoward Hinnant
2653e519524SHoward Hinnant    template <class T1, class _C1>
2663e519524SHoward Hinnant    friend
2673e519524SHoward Hinnant    bool
2683e519524SHoward Hinnant    operator< (const stack<T1, _C1>& __x, const stack<T1, _C1>& __y);
2693e519524SHoward Hinnant};
2703e519524SHoward Hinnant
271f3aed369SNikolas Klauser#if _LIBCPP_STD_VER > 14
2725b8b8b5dSMarshall Clowtemplate<class _Container,
2734e0ea2cfSLouis Dionne         class = enable_if_t<!__is_allocator<_Container>::value>
2745b8b8b5dSMarshall Clow>
2755b8b8b5dSMarshall Clowstack(_Container)
2765b8b8b5dSMarshall Clow    -> stack<typename _Container::value_type, _Container>;
2775b8b8b5dSMarshall Clow
2785b8b8b5dSMarshall Clowtemplate<class _Container,
2795b8b8b5dSMarshall Clow         class _Alloc,
2804e0ea2cfSLouis Dionne         class = enable_if_t<!__is_allocator<_Container>::value>,
2814e0ea2cfSLouis Dionne         class = enable_if_t<uses_allocator<_Container, _Alloc>::value>
2825b8b8b5dSMarshall Clow         >
2835b8b8b5dSMarshall Clowstack(_Container, _Alloc)
2845b8b8b5dSMarshall Clow    -> stack<typename _Container::value_type, _Container>;
2855b8b8b5dSMarshall Clow#endif
2865b8b8b5dSMarshall Clow
287f3aed369SNikolas Klauser#if _LIBCPP_STD_VER > 20
288f3aed369SNikolas Klausertemplate<class _InputIterator,
289f3aed369SNikolas Klauser         class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>>
290f3aed369SNikolas Klauserstack(_InputIterator, _InputIterator)
291f3aed369SNikolas Klauser    -> stack<__iter_value_type<_InputIterator>>;
292f3aed369SNikolas Klauser
293f3aed369SNikolas Klausertemplate<class _InputIterator,
294f3aed369SNikolas Klauser         class _Alloc,
295f3aed369SNikolas Klauser         class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
296f3aed369SNikolas Klauser         class = __enable_if_t<__is_allocator<_Alloc>::value>>
297f3aed369SNikolas Klauserstack(_InputIterator, _InputIterator, _Alloc)
298f3aed369SNikolas Klauser    -> stack<__iter_value_type<_InputIterator>, deque<__iter_value_type<_InputIterator>, _Alloc>>;
299f3aed369SNikolas Klauser#endif
300f3aed369SNikolas Klauser
3013e519524SHoward Hinnanttemplate <class _Tp, class _Container>
302e0601335SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY
3033e519524SHoward Hinnantbool
3043e519524SHoward Hinnantoperator==(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y)
3053e519524SHoward Hinnant{
3063e519524SHoward Hinnant    return __x.c == __y.c;
3073e519524SHoward Hinnant}
3083e519524SHoward Hinnant
3093e519524SHoward Hinnanttemplate <class _Tp, class _Container>
310e0601335SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY
3113e519524SHoward Hinnantbool
3123e519524SHoward Hinnantoperator< (const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y)
3133e519524SHoward Hinnant{
3143e519524SHoward Hinnant    return __x.c < __y.c;
3153e519524SHoward Hinnant}
3163e519524SHoward Hinnant
3173e519524SHoward Hinnanttemplate <class _Tp, class _Container>
318e0601335SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY
3193e519524SHoward Hinnantbool
3203e519524SHoward Hinnantoperator!=(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y)
3213e519524SHoward Hinnant{
3223e519524SHoward Hinnant    return !(__x == __y);
3233e519524SHoward Hinnant}
3243e519524SHoward Hinnant
3253e519524SHoward Hinnanttemplate <class _Tp, class _Container>
326e0601335SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY
3273e519524SHoward Hinnantbool
3283e519524SHoward Hinnantoperator> (const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y)
3293e519524SHoward Hinnant{
3303e519524SHoward Hinnant    return __y < __x;
3313e519524SHoward Hinnant}
3323e519524SHoward Hinnant
3333e519524SHoward Hinnanttemplate <class _Tp, class _Container>
334e0601335SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY
3353e519524SHoward Hinnantbool
3363e519524SHoward Hinnantoperator>=(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y)
3373e519524SHoward Hinnant{
3383e519524SHoward Hinnant    return !(__x < __y);
3393e519524SHoward Hinnant}
3403e519524SHoward Hinnant
3413e519524SHoward Hinnanttemplate <class _Tp, class _Container>
342e0601335SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY
3433e519524SHoward Hinnantbool
3443e519524SHoward Hinnantoperator<=(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y)
3453e519524SHoward Hinnant{
3463e519524SHoward Hinnant    return !(__y < __x);
3473e519524SHoward Hinnant}
3483e519524SHoward Hinnant
3493e519524SHoward Hinnanttemplate <class _Tp, class _Container>
350e0601335SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY
351b4e88d4dSLouis Dionne__enable_if_t<__is_swappable<_Container>::value, void>
3523e519524SHoward Hinnantswap(stack<_Tp, _Container>& __x, stack<_Tp, _Container>& __y)
353bd0c1600SHoward Hinnant    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
3543e519524SHoward Hinnant{
3553e519524SHoward Hinnant    __x.swap(__y);
3563e519524SHoward Hinnant}
3573e519524SHoward Hinnant
3583e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Alloc>
359e2f2d1edSEric Fiselierstruct _LIBCPP_TEMPLATE_VIS uses_allocator<stack<_Tp, _Container>, _Alloc>
3603e519524SHoward Hinnant    : public uses_allocator<_Container, _Alloc>
3613e519524SHoward Hinnant{
3623e519524SHoward Hinnant};
3633e519524SHoward Hinnant
3643e519524SHoward Hinnant_LIBCPP_END_NAMESPACE_STD
3653e519524SHoward Hinnant
3663e519524SHoward Hinnant#endif // _LIBCPP_STACK
367