10b57cec5SDimitry Andric// -*- C++ -*- 2349cc55cSDimitry Andric//===----------------------------------------------------------------------===// 30b57cec5SDimitry Andric// 40b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 50b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information. 60b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 70b57cec5SDimitry Andric// 80b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 90b57cec5SDimitry Andric 100b57cec5SDimitry Andric#ifndef _LIBCPP_STACK 110b57cec5SDimitry Andric#define _LIBCPP_STACK 120b57cec5SDimitry Andric 130b57cec5SDimitry Andric/* 140b57cec5SDimitry Andric stack synopsis 150b57cec5SDimitry Andric 160b57cec5SDimitry Andricnamespace std 170b57cec5SDimitry Andric{ 180b57cec5SDimitry Andric 190b57cec5SDimitry Andrictemplate <class T, class Container = deque<T>> 200b57cec5SDimitry Andricclass stack 210b57cec5SDimitry Andric{ 220b57cec5SDimitry Andricpublic: 230b57cec5SDimitry Andric typedef Container container_type; 240b57cec5SDimitry Andric typedef typename container_type::value_type value_type; 250b57cec5SDimitry Andric typedef typename container_type::reference reference; 260b57cec5SDimitry Andric typedef typename container_type::const_reference const_reference; 270b57cec5SDimitry Andric typedef typename container_type::size_type size_type; 280b57cec5SDimitry Andric 290b57cec5SDimitry Andricprotected: 300b57cec5SDimitry Andric container_type c; 310b57cec5SDimitry Andric 320b57cec5SDimitry Andricpublic: 330b57cec5SDimitry Andric stack() = default; 340b57cec5SDimitry Andric ~stack() = default; 350b57cec5SDimitry Andric 360b57cec5SDimitry Andric stack(const stack& q) = default; 370b57cec5SDimitry Andric stack(stack&& q) = default; 380b57cec5SDimitry Andric 390b57cec5SDimitry Andric stack& operator=(const stack& q) = default; 400b57cec5SDimitry Andric stack& operator=(stack&& q) = default; 410b57cec5SDimitry Andric 420b57cec5SDimitry Andric explicit stack(const container_type& c); 430b57cec5SDimitry Andric explicit stack(container_type&& c); 4404eeddc0SDimitry Andric template <class InputIterator> stack(InputIterator first, InputIterator last); // since C++23 450b57cec5SDimitry Andric template <class Alloc> explicit stack(const Alloc& a); 460b57cec5SDimitry Andric template <class Alloc> stack(const container_type& c, const Alloc& a); 470b57cec5SDimitry Andric template <class Alloc> stack(container_type&& c, const Alloc& a); 480b57cec5SDimitry Andric template <class Alloc> stack(const stack& c, const Alloc& a); 490b57cec5SDimitry Andric template <class Alloc> stack(stack&& c, const Alloc& a); 5004eeddc0SDimitry Andric template<class InputIterator, class Alloc> 5104eeddc0SDimitry Andric stack(InputIterator first, InputIterator last, const Alloc&); // since C++23 520b57cec5SDimitry Andric 530b57cec5SDimitry Andric bool empty() const; 540b57cec5SDimitry Andric size_type size() const; 550b57cec5SDimitry Andric reference top(); 560b57cec5SDimitry Andric const_reference top() const; 570b57cec5SDimitry Andric 580b57cec5SDimitry Andric void push(const value_type& x); 590b57cec5SDimitry Andric void push(value_type&& x); 600b57cec5SDimitry Andric template <class... Args> reference emplace(Args&&... args); // reference in C++17 610b57cec5SDimitry Andric void pop(); 620b57cec5SDimitry Andric 630b57cec5SDimitry Andric void swap(stack& c) noexcept(is_nothrow_swappable_v<Container>) 640b57cec5SDimitry Andric}; 650b57cec5SDimitry Andric 660b57cec5SDimitry Andrictemplate<class Container> 670b57cec5SDimitry Andric stack(Container) -> stack<typename Container::value_type, Container>; // C++17 680b57cec5SDimitry Andric 6904eeddc0SDimitry Andrictemplate<class InputIterator> 7004eeddc0SDimitry Andric stack(InputIterator, InputIterator) -> stack<iter-value-type<InputIterator>>; // since C++23 7104eeddc0SDimitry Andric 720b57cec5SDimitry Andrictemplate<class Container, class Allocator> 730b57cec5SDimitry Andric stack(Container, Allocator) -> stack<typename Container::value_type, Container>; // C++17 740b57cec5SDimitry Andric 7504eeddc0SDimitry Andrictemplate<class InputIterator, class Allocator> 7604eeddc0SDimitry Andric stack(InputIterator, InputIterator, Allocator) 7704eeddc0SDimitry Andric -> stack<iter-value-type<InputIterator>, 7804eeddc0SDimitry Andric deque<iter-value-type<InputIterator>, Allocator>>; // since C++23 7904eeddc0SDimitry Andric 800b57cec5SDimitry Andrictemplate <class T, class Container> 810b57cec5SDimitry Andric bool operator==(const stack<T, Container>& x, const stack<T, Container>& y); 820b57cec5SDimitry Andrictemplate <class T, class Container> 830b57cec5SDimitry Andric bool operator< (const stack<T, Container>& x, const stack<T, Container>& y); 840b57cec5SDimitry Andrictemplate <class T, class Container> 850b57cec5SDimitry Andric bool operator!=(const stack<T, Container>& x, const stack<T, Container>& y); 860b57cec5SDimitry Andrictemplate <class T, class Container> 870b57cec5SDimitry Andric bool operator> (const stack<T, Container>& x, const stack<T, Container>& y); 880b57cec5SDimitry Andrictemplate <class T, class Container> 890b57cec5SDimitry Andric bool operator>=(const stack<T, Container>& x, const stack<T, Container>& y); 900b57cec5SDimitry Andrictemplate <class T, class Container> 910b57cec5SDimitry Andric bool operator<=(const stack<T, Container>& x, const stack<T, Container>& y); 920b57cec5SDimitry Andric 930b57cec5SDimitry Andrictemplate <class T, class Container> 940b57cec5SDimitry Andric void swap(stack<T, Container>& x, stack<T, Container>& y) 950b57cec5SDimitry Andric noexcept(noexcept(x.swap(y))); 960b57cec5SDimitry Andric 970b57cec5SDimitry Andric} // std 980b57cec5SDimitry Andric 990b57cec5SDimitry Andric*/ 1000b57cec5SDimitry Andric 10181ad6265SDimitry Andric#include <__assert> // all public C++ headers provide the assertion handler 1020b57cec5SDimitry Andric#include <__config> 10304eeddc0SDimitry Andric#include <__iterator/iterator_traits.h> 104fe6060f1SDimitry Andric#include <__memory/uses_allocator.h> 105fe6060f1SDimitry Andric#include <__utility/forward.h> 1060b57cec5SDimitry Andric#include <deque> 10704eeddc0SDimitry Andric#include <type_traits> 10804eeddc0SDimitry Andric#include <version> 1090b57cec5SDimitry Andric 11081ad6265SDimitry Andric// standard-mandated includes 111*bdd1243dSDimitry Andric 112*bdd1243dSDimitry Andric// [stack.syn] 11381ad6265SDimitry Andric#include <compare> 11481ad6265SDimitry Andric#include <initializer_list> 11581ad6265SDimitry Andric 1160b57cec5SDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 1170b57cec5SDimitry Andric# pragma GCC system_header 1180b57cec5SDimitry Andric#endif 1190b57cec5SDimitry Andric 1200b57cec5SDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD 1210b57cec5SDimitry Andric 1220b57cec5SDimitry Andrictemplate <class _Tp, class _Container = deque<_Tp> > class _LIBCPP_TEMPLATE_VIS stack; 1230b57cec5SDimitry Andric 1240b57cec5SDimitry Andrictemplate <class _Tp, class _Container> 1250b57cec5SDimitry Andric_LIBCPP_INLINE_VISIBILITY 1260b57cec5SDimitry Andricbool 1270b57cec5SDimitry Andricoperator==(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y); 1280b57cec5SDimitry Andric 1290b57cec5SDimitry Andrictemplate <class _Tp, class _Container> 1300b57cec5SDimitry Andric_LIBCPP_INLINE_VISIBILITY 1310b57cec5SDimitry Andricbool 1320b57cec5SDimitry Andricoperator< (const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y); 1330b57cec5SDimitry Andric 1340b57cec5SDimitry Andrictemplate <class _Tp, class _Container /*= deque<_Tp>*/> 1350b57cec5SDimitry Andricclass _LIBCPP_TEMPLATE_VIS stack 1360b57cec5SDimitry Andric{ 1370b57cec5SDimitry Andricpublic: 1380b57cec5SDimitry Andric typedef _Container container_type; 1390b57cec5SDimitry Andric typedef typename container_type::value_type value_type; 1400b57cec5SDimitry Andric typedef typename container_type::reference reference; 1410b57cec5SDimitry Andric typedef typename container_type::const_reference const_reference; 1420b57cec5SDimitry Andric typedef typename container_type::size_type size_type; 1430b57cec5SDimitry Andric static_assert((is_same<_Tp, value_type>::value), "" ); 1440b57cec5SDimitry Andric 1450b57cec5SDimitry Andricprotected: 1460b57cec5SDimitry Andric container_type c; 1470b57cec5SDimitry Andric 1480b57cec5SDimitry Andricpublic: 1490b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1500b57cec5SDimitry Andric stack() 1510b57cec5SDimitry Andric _NOEXCEPT_(is_nothrow_default_constructible<container_type>::value) 1520b57cec5SDimitry Andric : c() {} 1530b57cec5SDimitry Andric 1540b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1550b57cec5SDimitry Andric stack(const stack& __q) : c(__q.c) {} 1560b57cec5SDimitry Andric 1570b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1580b57cec5SDimitry Andric stack& operator=(const stack& __q) {c = __q.c; return *this;} 1590b57cec5SDimitry Andric 1600b57cec5SDimitry Andric 1610b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 1620b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1630b57cec5SDimitry Andric stack(stack&& __q) 1640b57cec5SDimitry Andric _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value) 1650b57cec5SDimitry Andric : c(_VSTD::move(__q.c)) {} 1660b57cec5SDimitry Andric 1670b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1680b57cec5SDimitry Andric stack& operator=(stack&& __q) 1690b57cec5SDimitry Andric _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value) 1700b57cec5SDimitry Andric {c = _VSTD::move(__q.c); return *this;} 1710b57cec5SDimitry Andric 1720b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1730b57cec5SDimitry Andric explicit stack(container_type&& __c) : c(_VSTD::move(__c)) {} 1740b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 1750b57cec5SDimitry Andric 1760b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1770b57cec5SDimitry Andric explicit stack(const container_type& __c) : c(__c) {} 1780b57cec5SDimitry Andric 1790b57cec5SDimitry Andric template <class _Alloc> 1800b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1810b57cec5SDimitry Andric explicit stack(const _Alloc& __a, 182349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) 1830b57cec5SDimitry Andric : c(__a) {} 1840b57cec5SDimitry Andric template <class _Alloc> 1850b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1860b57cec5SDimitry Andric stack(const container_type& __c, const _Alloc& __a, 187349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) 1880b57cec5SDimitry Andric : c(__c, __a) {} 1890b57cec5SDimitry Andric template <class _Alloc> 1900b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1910b57cec5SDimitry Andric stack(const stack& __s, const _Alloc& __a, 192349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) 1930b57cec5SDimitry Andric : c(__s.c, __a) {} 1940b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 1950b57cec5SDimitry Andric template <class _Alloc> 1960b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1970b57cec5SDimitry Andric stack(container_type&& __c, const _Alloc& __a, 198349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) 1990b57cec5SDimitry Andric : c(_VSTD::move(__c), __a) {} 2000b57cec5SDimitry Andric template <class _Alloc> 2010b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 2020b57cec5SDimitry Andric stack(stack&& __s, const _Alloc& __a, 203349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) 2040b57cec5SDimitry Andric : c(_VSTD::move(__s.c), __a) {} 2050b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 2060b57cec5SDimitry Andric 20704eeddc0SDimitry Andric#if _LIBCPP_STD_VER > 20 20804eeddc0SDimitry Andric template <class _InputIterator, 20904eeddc0SDimitry Andric class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>> 21004eeddc0SDimitry Andric _LIBCPP_HIDE_FROM_ABI 21104eeddc0SDimitry Andric stack(_InputIterator __first, _InputIterator __last) : c(__first, __last) {} 21204eeddc0SDimitry Andric 21304eeddc0SDimitry Andric template <class _InputIterator, 21404eeddc0SDimitry Andric class _Alloc, 21504eeddc0SDimitry Andric class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, 21604eeddc0SDimitry Andric class = __enable_if_t<uses_allocator<container_type, _Alloc>::value>> 21704eeddc0SDimitry Andric _LIBCPP_HIDE_FROM_ABI 21804eeddc0SDimitry Andric stack(_InputIterator __first, _InputIterator __last, const _Alloc& __alloc) : c(__first, __last, __alloc) {} 21904eeddc0SDimitry Andric#endif 22004eeddc0SDimitry Andric 2210b57cec5SDimitry Andric _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY 2220b57cec5SDimitry Andric bool empty() const {return c.empty();} 2230b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 2240b57cec5SDimitry Andric size_type size() const {return c.size();} 2250b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 2260b57cec5SDimitry Andric reference top() {return c.back();} 2270b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 2280b57cec5SDimitry Andric const_reference top() const {return c.back();} 2290b57cec5SDimitry Andric 2300b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 2310b57cec5SDimitry Andric void push(const value_type& __v) {c.push_back(__v);} 2320b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 2330b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 2340b57cec5SDimitry Andric void push(value_type&& __v) {c.push_back(_VSTD::move(__v));} 2350b57cec5SDimitry Andric 2360b57cec5SDimitry Andric template <class... _Args> 2370b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 2380b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 14 2390b57cec5SDimitry Andric decltype(auto) emplace(_Args&&... __args) 2400b57cec5SDimitry Andric { return c.emplace_back(_VSTD::forward<_Args>(__args)...);} 2410b57cec5SDimitry Andric#else 2420b57cec5SDimitry Andric void emplace(_Args&&... __args) 2430b57cec5SDimitry Andric { c.emplace_back(_VSTD::forward<_Args>(__args)...);} 2440b57cec5SDimitry Andric#endif 2450b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 2460b57cec5SDimitry Andric 2470b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 2480b57cec5SDimitry Andric void pop() {c.pop_back();} 2490b57cec5SDimitry Andric 2500b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 2510b57cec5SDimitry Andric void swap(stack& __s) 2520b57cec5SDimitry Andric _NOEXCEPT_(__is_nothrow_swappable<container_type>::value) 2530b57cec5SDimitry Andric { 2540b57cec5SDimitry Andric using _VSTD::swap; 2550b57cec5SDimitry Andric swap(c, __s.c); 2560b57cec5SDimitry Andric } 2570b57cec5SDimitry Andric 258*bdd1243dSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; } 259*bdd1243dSDimitry Andric 2600b57cec5SDimitry Andric template <class T1, class _C1> 2610b57cec5SDimitry Andric friend 2620b57cec5SDimitry Andric bool 2630b57cec5SDimitry Andric operator==(const stack<T1, _C1>& __x, const stack<T1, _C1>& __y); 2640b57cec5SDimitry Andric 2650b57cec5SDimitry Andric template <class T1, class _C1> 2660b57cec5SDimitry Andric friend 2670b57cec5SDimitry Andric bool 2680b57cec5SDimitry Andric operator< (const stack<T1, _C1>& __x, const stack<T1, _C1>& __y); 2690b57cec5SDimitry Andric}; 2700b57cec5SDimitry Andric 27104eeddc0SDimitry Andric#if _LIBCPP_STD_VER > 14 2720b57cec5SDimitry Andrictemplate<class _Container, 273349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Container>::value> 2740b57cec5SDimitry Andric> 2750b57cec5SDimitry Andricstack(_Container) 2760b57cec5SDimitry Andric -> stack<typename _Container::value_type, _Container>; 2770b57cec5SDimitry Andric 2780b57cec5SDimitry Andrictemplate<class _Container, 2790b57cec5SDimitry Andric class _Alloc, 280349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Container>::value>, 281349cc55cSDimitry Andric class = enable_if_t<uses_allocator<_Container, _Alloc>::value> 2820b57cec5SDimitry Andric > 2830b57cec5SDimitry Andricstack(_Container, _Alloc) 2840b57cec5SDimitry Andric -> stack<typename _Container::value_type, _Container>; 2850b57cec5SDimitry Andric#endif 2860b57cec5SDimitry Andric 28704eeddc0SDimitry Andric#if _LIBCPP_STD_VER > 20 28804eeddc0SDimitry Andrictemplate<class _InputIterator, 28904eeddc0SDimitry Andric class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>> 29004eeddc0SDimitry Andricstack(_InputIterator, _InputIterator) 29104eeddc0SDimitry Andric -> stack<__iter_value_type<_InputIterator>>; 29204eeddc0SDimitry Andric 29304eeddc0SDimitry Andrictemplate<class _InputIterator, 29404eeddc0SDimitry Andric class _Alloc, 29504eeddc0SDimitry Andric class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, 29604eeddc0SDimitry Andric class = __enable_if_t<__is_allocator<_Alloc>::value>> 29704eeddc0SDimitry Andricstack(_InputIterator, _InputIterator, _Alloc) 29804eeddc0SDimitry Andric -> stack<__iter_value_type<_InputIterator>, deque<__iter_value_type<_InputIterator>, _Alloc>>; 29904eeddc0SDimitry Andric#endif 30004eeddc0SDimitry Andric 3010b57cec5SDimitry Andrictemplate <class _Tp, class _Container> 3020b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 3030b57cec5SDimitry Andricbool 3040b57cec5SDimitry Andricoperator==(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y) 3050b57cec5SDimitry Andric{ 3060b57cec5SDimitry Andric return __x.c == __y.c; 3070b57cec5SDimitry Andric} 3080b57cec5SDimitry Andric 3090b57cec5SDimitry Andrictemplate <class _Tp, class _Container> 3100b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 3110b57cec5SDimitry Andricbool 3120b57cec5SDimitry Andricoperator< (const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y) 3130b57cec5SDimitry Andric{ 3140b57cec5SDimitry Andric return __x.c < __y.c; 3150b57cec5SDimitry Andric} 3160b57cec5SDimitry Andric 3170b57cec5SDimitry Andrictemplate <class _Tp, class _Container> 3180b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 3190b57cec5SDimitry Andricbool 3200b57cec5SDimitry Andricoperator!=(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y) 3210b57cec5SDimitry Andric{ 3220b57cec5SDimitry Andric return !(__x == __y); 3230b57cec5SDimitry Andric} 3240b57cec5SDimitry Andric 3250b57cec5SDimitry Andrictemplate <class _Tp, class _Container> 3260b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 3270b57cec5SDimitry Andricbool 3280b57cec5SDimitry Andricoperator> (const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y) 3290b57cec5SDimitry Andric{ 3300b57cec5SDimitry Andric return __y < __x; 3310b57cec5SDimitry Andric} 3320b57cec5SDimitry Andric 3330b57cec5SDimitry Andrictemplate <class _Tp, class _Container> 3340b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 3350b57cec5SDimitry Andricbool 3360b57cec5SDimitry Andricoperator>=(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y) 3370b57cec5SDimitry Andric{ 3380b57cec5SDimitry Andric return !(__x < __y); 3390b57cec5SDimitry Andric} 3400b57cec5SDimitry Andric 3410b57cec5SDimitry Andrictemplate <class _Tp, class _Container> 3420b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 3430b57cec5SDimitry Andricbool 3440b57cec5SDimitry Andricoperator<=(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y) 3450b57cec5SDimitry Andric{ 3460b57cec5SDimitry Andric return !(__y < __x); 3470b57cec5SDimitry Andric} 3480b57cec5SDimitry Andric 3490b57cec5SDimitry Andrictemplate <class _Tp, class _Container> 3500b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 351349cc55cSDimitry Andric__enable_if_t<__is_swappable<_Container>::value, void> 3520b57cec5SDimitry Andricswap(stack<_Tp, _Container>& __x, stack<_Tp, _Container>& __y) 3530b57cec5SDimitry Andric _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) 3540b57cec5SDimitry Andric{ 3550b57cec5SDimitry Andric __x.swap(__y); 3560b57cec5SDimitry Andric} 3570b57cec5SDimitry Andric 3580b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Alloc> 3590b57cec5SDimitry Andricstruct _LIBCPP_TEMPLATE_VIS uses_allocator<stack<_Tp, _Container>, _Alloc> 3600b57cec5SDimitry Andric : public uses_allocator<_Container, _Alloc> 3610b57cec5SDimitry Andric{ 3620b57cec5SDimitry Andric}; 3630b57cec5SDimitry Andric 3640b57cec5SDimitry Andric_LIBCPP_END_NAMESPACE_STD 3650b57cec5SDimitry Andric 366*bdd1243dSDimitry Andric#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 367*bdd1243dSDimitry Andric# include <concepts> 368*bdd1243dSDimitry Andric# include <functional> 369*bdd1243dSDimitry Andric#endif 370*bdd1243dSDimitry Andric 3710b57cec5SDimitry Andric#endif // _LIBCPP_STACK 372