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 4506c3fb27SDimitry Andric template<container-compatible-range<T> R> stack(from_range_t, R&& rg); // since C++23 460b57cec5SDimitry Andric template <class Alloc> explicit stack(const Alloc& a); 470b57cec5SDimitry Andric template <class Alloc> stack(const container_type& c, const Alloc& a); 480b57cec5SDimitry Andric template <class Alloc> stack(container_type&& c, const Alloc& a); 490b57cec5SDimitry Andric template <class Alloc> stack(const stack& c, const Alloc& a); 500b57cec5SDimitry Andric template <class Alloc> stack(stack&& c, const Alloc& a); 5104eeddc0SDimitry Andric template<class InputIterator, class Alloc> 5204eeddc0SDimitry Andric stack(InputIterator first, InputIterator last, const Alloc&); // since C++23 5306c3fb27SDimitry Andric template<container-compatible-range<T> R, class Alloc> 5406c3fb27SDimitry Andric stack(from_range_t, R&& rg, const Alloc&); // since C++23 550b57cec5SDimitry Andric 560b57cec5SDimitry Andric bool empty() const; 570b57cec5SDimitry Andric size_type size() const; 580b57cec5SDimitry Andric reference top(); 590b57cec5SDimitry Andric const_reference top() const; 600b57cec5SDimitry Andric 610b57cec5SDimitry Andric void push(const value_type& x); 620b57cec5SDimitry Andric void push(value_type&& x); 6306c3fb27SDimitry Andric template<container-compatible-range<T> R> 6406c3fb27SDimitry Andric void push_range(R&& rg); // C++23 650b57cec5SDimitry Andric template <class... Args> reference emplace(Args&&... args); // reference in C++17 660b57cec5SDimitry Andric void pop(); 670b57cec5SDimitry Andric 680b57cec5SDimitry Andric void swap(stack& c) noexcept(is_nothrow_swappable_v<Container>) 690b57cec5SDimitry Andric}; 700b57cec5SDimitry Andric 710b57cec5SDimitry Andrictemplate<class Container> 720b57cec5SDimitry Andric stack(Container) -> stack<typename Container::value_type, Container>; // C++17 730b57cec5SDimitry Andric 7404eeddc0SDimitry Andrictemplate<class InputIterator> 7504eeddc0SDimitry Andric stack(InputIterator, InputIterator) -> stack<iter-value-type<InputIterator>>; // since C++23 7604eeddc0SDimitry Andric 7706c3fb27SDimitry Andrictemplate<ranges::input_range R> 7806c3fb27SDimitry Andric stack(from_range_t, R&&) -> stack<ranges::range_value_t<R>>; // since C++23 7906c3fb27SDimitry Andric 800b57cec5SDimitry Andrictemplate<class Container, class Allocator> 810b57cec5SDimitry Andric stack(Container, Allocator) -> stack<typename Container::value_type, Container>; // C++17 820b57cec5SDimitry Andric 8304eeddc0SDimitry Andrictemplate<class InputIterator, class Allocator> 8404eeddc0SDimitry Andric stack(InputIterator, InputIterator, Allocator) 8504eeddc0SDimitry Andric -> stack<iter-value-type<InputIterator>, 8604eeddc0SDimitry Andric deque<iter-value-type<InputIterator>, Allocator>>; // since C++23 8704eeddc0SDimitry Andric 8806c3fb27SDimitry Andrictemplate<ranges::input_range R, class Allocator> 8906c3fb27SDimitry Andric stack(from_range_t, R&&, Allocator) 9006c3fb27SDimitry Andric -> stack<ranges::range_value_t<R>, deque<ranges::range_value_t<R>, Allocator>>; // since C++23 9106c3fb27SDimitry Andric 920b57cec5SDimitry Andrictemplate <class T, class Container> 930b57cec5SDimitry Andric bool operator==(const stack<T, Container>& x, const stack<T, Container>& y); 940b57cec5SDimitry Andrictemplate <class T, class Container> 950b57cec5SDimitry Andric bool operator< (const stack<T, Container>& x, const stack<T, Container>& y); 960b57cec5SDimitry Andrictemplate <class T, class Container> 970b57cec5SDimitry Andric bool operator!=(const stack<T, Container>& x, const stack<T, Container>& y); 980b57cec5SDimitry Andrictemplate <class T, class Container> 990b57cec5SDimitry Andric bool operator> (const stack<T, Container>& x, const stack<T, Container>& y); 1000b57cec5SDimitry Andrictemplate <class T, class Container> 1010b57cec5SDimitry Andric bool operator>=(const stack<T, Container>& x, const stack<T, Container>& y); 1020b57cec5SDimitry Andrictemplate <class T, class Container> 1030b57cec5SDimitry Andric bool operator<=(const stack<T, Container>& x, const stack<T, Container>& y); 10406c3fb27SDimitry Andrictemplate<class T, three_way_comparable Container> 10506c3fb27SDimitry Andric compare_three_way_result_t<Container> 10606c3fb27SDimitry Andric operator<=>(const stack<T, Container>& x, const stack<T, Container>& y); // since C++20 1070b57cec5SDimitry Andric 1080b57cec5SDimitry Andrictemplate <class T, class Container> 1090b57cec5SDimitry Andric void swap(stack<T, Container>& x, stack<T, Container>& y) 1100b57cec5SDimitry Andric noexcept(noexcept(x.swap(y))); 1110b57cec5SDimitry Andric 1120b57cec5SDimitry Andric} // std 1130b57cec5SDimitry Andric 1140b57cec5SDimitry Andric*/ 1150b57cec5SDimitry Andric 116*700637cbSDimitry Andric#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) 117*700637cbSDimitry Andric# include <__cxx03/stack> 118*700637cbSDimitry Andric#else 11906c3fb27SDimitry Andric# include <__algorithm/ranges_copy.h> 1200b57cec5SDimitry Andric# include <__config> 1210fca6ea1SDimitry Andric# include <__fwd/stack.h> 12206c3fb27SDimitry Andric# include <__iterator/back_insert_iterator.h> 12304eeddc0SDimitry Andric# include <__iterator/iterator_traits.h> 124fe6060f1SDimitry Andric# include <__memory/uses_allocator.h> 12506c3fb27SDimitry Andric# include <__ranges/access.h> 12606c3fb27SDimitry Andric# include <__ranges/concepts.h> 12706c3fb27SDimitry Andric# include <__ranges/container_compatible_range.h> 12806c3fb27SDimitry Andric# include <__ranges/from_range.h> 12906c3fb27SDimitry Andric# include <__type_traits/is_same.h> 130fe6060f1SDimitry Andric# include <__utility/forward.h> 1310b57cec5SDimitry Andric# include <deque> 13204eeddc0SDimitry Andric# include <version> 1330b57cec5SDimitry Andric 13481ad6265SDimitry Andric// standard-mandated includes 135bdd1243dSDimitry Andric 136bdd1243dSDimitry Andric// [stack.syn] 13781ad6265SDimitry Andric# include <compare> 13881ad6265SDimitry Andric# include <initializer_list> 13981ad6265SDimitry Andric 1400b57cec5SDimitry Andric# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 1410b57cec5SDimitry Andric# pragma GCC system_header 1420b57cec5SDimitry Andric# endif 1430b57cec5SDimitry Andric 144b3edf446SDimitry Andric_LIBCPP_PUSH_MACROS 145b3edf446SDimitry Andric# include <__undef_macros> 146b3edf446SDimitry Andric 1470b57cec5SDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD 1480b57cec5SDimitry Andric 1490b57cec5SDimitry Andrictemplate <class _Tp, class _Container> 150cb14a3feSDimitry Andric_LIBCPP_HIDE_FROM_ABI bool operator==(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y); 1510b57cec5SDimitry Andric 1520b57cec5SDimitry Andrictemplate <class _Tp, class _Container> 153cb14a3feSDimitry Andric_LIBCPP_HIDE_FROM_ABI bool operator<(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y); 1540b57cec5SDimitry Andric 1550b57cec5SDimitry Andrictemplate <class _Tp, class _Container /*= deque<_Tp>*/> 156*700637cbSDimitry Andricclass stack { 1570b57cec5SDimitry Andricpublic: 1580b57cec5SDimitry Andric typedef _Container container_type; 1590b57cec5SDimitry Andric typedef typename container_type::value_type value_type; 1600b57cec5SDimitry Andric typedef typename container_type::reference reference; 1610b57cec5SDimitry Andric typedef typename container_type::const_reference const_reference; 1620b57cec5SDimitry Andric typedef typename container_type::size_type size_type; 1630fca6ea1SDimitry Andric static_assert(is_same<_Tp, value_type>::value, ""); 1640b57cec5SDimitry Andric 1650b57cec5SDimitry Andricprotected: 1660b57cec5SDimitry Andric container_type c; 1670b57cec5SDimitry Andric 1680b57cec5SDimitry Andricpublic: 169cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI stack() _NOEXCEPT_(is_nothrow_default_constructible<container_type>::value) : c() {} 1700b57cec5SDimitry Andric 171cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI stack(const stack& __q) : c(__q.c) {} 1720b57cec5SDimitry Andric 173cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI stack& operator=(const stack& __q) { 174cb14a3feSDimitry Andric c = __q.c; 175cb14a3feSDimitry Andric return *this; 176cb14a3feSDimitry Andric } 1770b57cec5SDimitry Andric 1780b57cec5SDimitry Andric# ifndef _LIBCPP_CXX03_LANG 1790fca6ea1SDimitry Andric _LIBCPP_HIDE_FROM_ABI stack(stack&& __q) noexcept(is_nothrow_move_constructible<container_type>::value) 1805f757f3fSDimitry Andric : c(std::move(__q.c)) {} 1810b57cec5SDimitry Andric 1820fca6ea1SDimitry Andric _LIBCPP_HIDE_FROM_ABI stack& operator=(stack&& __q) noexcept(is_nothrow_move_assignable<container_type>::value) { 183cb14a3feSDimitry Andric c = std::move(__q.c); 184cb14a3feSDimitry Andric return *this; 185cb14a3feSDimitry Andric } 1860b57cec5SDimitry Andric 187cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI explicit stack(container_type&& __c) : c(std::move(__c)) {} 1880b57cec5SDimitry Andric# endif // _LIBCPP_CXX03_LANG 1890b57cec5SDimitry Andric 190cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI explicit stack(const container_type& __c) : c(__c) {} 1910b57cec5SDimitry Andric 1920b57cec5SDimitry Andric template <class _Alloc> 193cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI explicit stack(const _Alloc& __a, 194349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) 1950b57cec5SDimitry Andric : c(__a) {} 1960b57cec5SDimitry Andric template <class _Alloc> 1975f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 198cb14a3feSDimitry Andric stack(const container_type& __c, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) 1990b57cec5SDimitry Andric : c(__c, __a) {} 2000b57cec5SDimitry Andric template <class _Alloc> 2015f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 202cb14a3feSDimitry Andric stack(const stack& __s, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) 2030b57cec5SDimitry Andric : c(__s.c, __a) {} 2040b57cec5SDimitry Andric# ifndef _LIBCPP_CXX03_LANG 2050b57cec5SDimitry Andric template <class _Alloc> 2065f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 207cb14a3feSDimitry Andric stack(container_type&& __c, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) 2085f757f3fSDimitry Andric : c(std::move(__c), __a) {} 2090b57cec5SDimitry Andric template <class _Alloc> 2105f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 211cb14a3feSDimitry Andric stack(stack&& __s, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) 2125f757f3fSDimitry Andric : c(std::move(__s.c), __a) {} 2130b57cec5SDimitry Andric# endif // _LIBCPP_CXX03_LANG 2140b57cec5SDimitry Andric 21506c3fb27SDimitry Andric# if _LIBCPP_STD_VER >= 23 2160fca6ea1SDimitry Andric template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0> 217cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI stack(_InputIterator __first, _InputIterator __last) : c(__first, __last) {} 21804eeddc0SDimitry Andric 21906c3fb27SDimitry Andric template <_ContainerCompatibleRange<_Tp> _Range> 220cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI stack(from_range_t, _Range&& __range) : c(from_range, std::forward<_Range>(__range)) {} 22106c3fb27SDimitry Andric 22204eeddc0SDimitry Andric template <class _InputIterator, 22304eeddc0SDimitry Andric class _Alloc, 2240fca6ea1SDimitry Andric __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0, 2250fca6ea1SDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0> 226cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI stack(_InputIterator __first, _InputIterator __last, const _Alloc& __alloc) 227cb14a3feSDimitry Andric : c(__first, __last, __alloc) {} 22806c3fb27SDimitry Andric 22906c3fb27SDimitry Andric template <_ContainerCompatibleRange<_Tp> _Range, 23006c3fb27SDimitry Andric class _Alloc, 2310fca6ea1SDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0> 232cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI stack(from_range_t, _Range&& __range, const _Alloc& __alloc) 23306c3fb27SDimitry Andric : c(from_range, std::forward<_Range>(__range), __alloc) {} 23406c3fb27SDimitry Andric 23504eeddc0SDimitry Andric# endif 23604eeddc0SDimitry Andric 237*700637cbSDimitry Andric [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); } 238cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI size_type size() const { return c.size(); } 239cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI reference top() { return c.back(); } 240cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_reference top() const { return c.back(); } 2410b57cec5SDimitry Andric 242cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI void push(const value_type& __v) { c.push_back(__v); } 2430b57cec5SDimitry Andric# ifndef _LIBCPP_CXX03_LANG 244cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI void push(value_type&& __v) { c.push_back(std::move(__v)); } 2450b57cec5SDimitry Andric 24606c3fb27SDimitry Andric# if _LIBCPP_STD_VER >= 23 24706c3fb27SDimitry Andric template <_ContainerCompatibleRange<_Tp> _Range> 248cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI void push_range(_Range&& __range) { 249cb14a3feSDimitry Andric if constexpr (requires(container_type& __c) { __c.append_range(std::forward<_Range>(__range)); }) { 25006c3fb27SDimitry Andric c.append_range(std::forward<_Range>(__range)); 25106c3fb27SDimitry Andric } else { 25206c3fb27SDimitry Andric ranges::copy(std::forward<_Range>(__range), std::back_inserter(c)); 25306c3fb27SDimitry Andric } 25406c3fb27SDimitry Andric } 25506c3fb27SDimitry Andric# endif 25606c3fb27SDimitry Andric 2570b57cec5SDimitry Andric template <class... _Args> 2585f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 25906c3fb27SDimitry Andric# if _LIBCPP_STD_VER >= 17 260cb14a3feSDimitry Andric decltype(auto) 261cb14a3feSDimitry Andric emplace(_Args&&... __args) { 262cb14a3feSDimitry Andric return c.emplace_back(std::forward<_Args>(__args)...); 263cb14a3feSDimitry Andric } 2640b57cec5SDimitry Andric# else 265cb14a3feSDimitry Andric void 266cb14a3feSDimitry Andric emplace(_Args&&... __args) { 267cb14a3feSDimitry Andric c.emplace_back(std::forward<_Args>(__args)...); 268cb14a3feSDimitry Andric } 2690b57cec5SDimitry Andric# endif 2700b57cec5SDimitry Andric# endif // _LIBCPP_CXX03_LANG 2710b57cec5SDimitry Andric 272cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI void pop() { c.pop_back(); } 2730b57cec5SDimitry Andric 2740fca6ea1SDimitry Andric _LIBCPP_HIDE_FROM_ABI void swap(stack& __s) _NOEXCEPT_(__is_nothrow_swappable_v<container_type>) { 2755f757f3fSDimitry Andric using std::swap; 2760b57cec5SDimitry Andric swap(c, __s.c); 2770b57cec5SDimitry Andric } 2780b57cec5SDimitry Andric 279*700637cbSDimitry Andric [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; } 280bdd1243dSDimitry Andric 28106c3fb27SDimitry Andric template <class _T1, class _OtherContainer> 282*700637cbSDimitry Andric friend _LIBCPP_HIDE_FROM_ABI bool 283*700637cbSDimitry Andric operator==(const stack<_T1, _OtherContainer>& __x, const stack<_T1, _OtherContainer>& __y); 2840b57cec5SDimitry Andric 28506c3fb27SDimitry Andric template <class _T1, class _OtherContainer> 286*700637cbSDimitry Andric friend _LIBCPP_HIDE_FROM_ABI bool 287*700637cbSDimitry Andric operator<(const stack<_T1, _OtherContainer>& __x, const stack<_T1, _OtherContainer>& __y); 288*700637cbSDimitry Andric 289*700637cbSDimitry Andric# if _LIBCPP_STD_VER >= 20 290*700637cbSDimitry Andric template <class _T1, three_way_comparable _OtherContainer> 291*700637cbSDimitry Andric friend _LIBCPP_HIDE_FROM_ABI compare_three_way_result_t<_OtherContainer> 292*700637cbSDimitry Andric operator<=>(const stack<_T1, _OtherContainer>& __x, const stack<_T1, _OtherContainer>& __y); 293*700637cbSDimitry Andric# endif 2940b57cec5SDimitry Andric}; 2950b57cec5SDimitry Andric 29606c3fb27SDimitry Andric# if _LIBCPP_STD_VER >= 17 297cb14a3feSDimitry Andrictemplate <class _Container, class = enable_if_t<!__is_allocator<_Container>::value> > 298cb14a3feSDimitry Andricstack(_Container) -> stack<typename _Container::value_type, _Container>; 2990b57cec5SDimitry Andric 3000b57cec5SDimitry Andrictemplate <class _Container, 3010b57cec5SDimitry Andric class _Alloc, 302349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Container>::value>, 303cb14a3feSDimitry Andric class = enable_if_t<uses_allocator<_Container, _Alloc>::value> > 304cb14a3feSDimitry Andricstack(_Container, _Alloc) -> stack<typename _Container::value_type, _Container>; 3050b57cec5SDimitry Andric# endif 3060b57cec5SDimitry Andric 30706c3fb27SDimitry Andric# if _LIBCPP_STD_VER >= 23 3080fca6ea1SDimitry Andrictemplate <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0> 309cb14a3feSDimitry Andricstack(_InputIterator, _InputIterator) -> stack<__iter_value_type<_InputIterator>>; 31004eeddc0SDimitry Andric 31106c3fb27SDimitry Andrictemplate <ranges::input_range _Range> 31206c3fb27SDimitry Andricstack(from_range_t, _Range&&) -> stack<ranges::range_value_t<_Range>>; 31306c3fb27SDimitry Andric 31404eeddc0SDimitry Andrictemplate <class _InputIterator, 31504eeddc0SDimitry Andric class _Alloc, 3160fca6ea1SDimitry Andric __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0, 3170fca6ea1SDimitry Andric __enable_if_t<__is_allocator<_Alloc>::value, int> = 0> 3180fca6ea1SDimitry Andricstack(_InputIterator, 3190fca6ea1SDimitry Andric _InputIterator, 3200fca6ea1SDimitry Andric _Alloc) -> stack<__iter_value_type<_InputIterator>, deque<__iter_value_type<_InputIterator>, _Alloc>>; 32106c3fb27SDimitry Andric 3220fca6ea1SDimitry Andrictemplate <ranges::input_range _Range, class _Alloc, __enable_if_t<__is_allocator<_Alloc>::value, int> = 0> 3230fca6ea1SDimitry Andricstack(from_range_t, 3240fca6ea1SDimitry Andric _Range&&, 3250fca6ea1SDimitry Andric _Alloc) -> stack<ranges::range_value_t<_Range>, deque<ranges::range_value_t<_Range>, _Alloc>>; 32606c3fb27SDimitry Andric 32704eeddc0SDimitry Andric# endif 32804eeddc0SDimitry Andric 3290b57cec5SDimitry Andrictemplate <class _Tp, class _Container> 330cb14a3feSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool operator==(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y) { 3310b57cec5SDimitry Andric return __x.c == __y.c; 3320b57cec5SDimitry Andric} 3330b57cec5SDimitry Andric 3340b57cec5SDimitry Andrictemplate <class _Tp, class _Container> 335cb14a3feSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool operator<(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y) { 3360b57cec5SDimitry Andric return __x.c < __y.c; 3370b57cec5SDimitry Andric} 3380b57cec5SDimitry Andric 3390b57cec5SDimitry Andrictemplate <class _Tp, class _Container> 340cb14a3feSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool operator!=(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y) { 3410b57cec5SDimitry Andric return !(__x == __y); 3420b57cec5SDimitry Andric} 3430b57cec5SDimitry Andric 3440b57cec5SDimitry Andrictemplate <class _Tp, class _Container> 345cb14a3feSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool operator>(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y) { 3460b57cec5SDimitry Andric return __y < __x; 3470b57cec5SDimitry Andric} 3480b57cec5SDimitry Andric 3490b57cec5SDimitry Andrictemplate <class _Tp, class _Container> 350cb14a3feSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool operator>=(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y) { 3510b57cec5SDimitry Andric return !(__x < __y); 3520b57cec5SDimitry Andric} 3530b57cec5SDimitry Andric 3540b57cec5SDimitry Andrictemplate <class _Tp, class _Container> 355cb14a3feSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool operator<=(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y) { 3560b57cec5SDimitry Andric return !(__y < __x); 3570b57cec5SDimitry Andric} 3580b57cec5SDimitry Andric 35906c3fb27SDimitry Andric# if _LIBCPP_STD_VER >= 20 36006c3fb27SDimitry Andric 36106c3fb27SDimitry Andrictemplate <class _Tp, three_way_comparable _Container> 36206c3fb27SDimitry Andric_LIBCPP_HIDE_FROM_ABI compare_three_way_result_t<_Container> 36306c3fb27SDimitry Andricoperator<=>(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y) { 364*700637cbSDimitry Andric return __x.c <=> __y.c; 36506c3fb27SDimitry Andric} 36606c3fb27SDimitry Andric 36706c3fb27SDimitry Andric# endif 36806c3fb27SDimitry Andric 3690fca6ea1SDimitry Andrictemplate <class _Tp, class _Container, __enable_if_t<__is_swappable_v<_Container>, int> = 0> 370cb14a3feSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI void swap(stack<_Tp, _Container>& __x, stack<_Tp, _Container>& __y) 371cb14a3feSDimitry Andric _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) { 3720b57cec5SDimitry Andric __x.swap(__y); 3730b57cec5SDimitry Andric} 3740b57cec5SDimitry Andric 3750b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Alloc> 376*700637cbSDimitry Andricstruct uses_allocator<stack<_Tp, _Container>, _Alloc> : public uses_allocator<_Container, _Alloc> {}; 3770b57cec5SDimitry Andric 3780b57cec5SDimitry Andric_LIBCPP_END_NAMESPACE_STD 3790b57cec5SDimitry Andric 380b3edf446SDimitry Andric_LIBCPP_POP_MACROS 381b3edf446SDimitry Andric 382bdd1243dSDimitry Andric# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 383bdd1243dSDimitry Andric# include <concepts> 384bdd1243dSDimitry Andric# include <functional> 38506c3fb27SDimitry Andric# include <type_traits> 386bdd1243dSDimitry Andric# endif 387*700637cbSDimitry Andric#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) 388bdd1243dSDimitry Andric 3890b57cec5SDimitry Andric#endif // _LIBCPP_STACK 390