2010-05-12 03:42:16 +08:00
|
|
|
// -*- C++ -*-
|
2021-11-18 05:25:01 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2010-05-12 03:42:16 +08:00
|
|
|
//
|
2019-01-19 18:56:40 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2010-05-12 03:42:16 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef _LIBCPP_STACK
|
|
|
|
#define _LIBCPP_STACK
|
|
|
|
|
|
|
|
/*
|
|
|
|
stack synopsis
|
|
|
|
|
|
|
|
namespace std
|
|
|
|
{
|
|
|
|
|
|
|
|
template <class T, class Container = deque<T>>
|
|
|
|
class stack
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef Container container_type;
|
|
|
|
typedef typename container_type::value_type value_type;
|
|
|
|
typedef typename container_type::reference reference;
|
|
|
|
typedef typename container_type::const_reference const_reference;
|
|
|
|
typedef typename container_type::size_type size_type;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
container_type c;
|
|
|
|
|
|
|
|
public:
|
2011-06-05 06:09:19 +08:00
|
|
|
stack() = default;
|
|
|
|
~stack() = default;
|
|
|
|
|
|
|
|
stack(const stack& q) = default;
|
|
|
|
stack(stack&& q) = default;
|
|
|
|
|
|
|
|
stack& operator=(const stack& q) = default;
|
|
|
|
stack& operator=(stack&& q) = default;
|
|
|
|
|
2010-05-12 03:42:16 +08:00
|
|
|
explicit stack(const container_type& c);
|
|
|
|
explicit stack(container_type&& c);
|
2022-01-06 19:36:07 +08:00
|
|
|
template <class InputIterator> stack(InputIterator first, InputIterator last); // since C++23
|
2010-05-12 03:42:16 +08:00
|
|
|
template <class Alloc> explicit stack(const Alloc& a);
|
|
|
|
template <class Alloc> stack(const container_type& c, const Alloc& a);
|
|
|
|
template <class Alloc> stack(container_type&& c, const Alloc& a);
|
2011-06-05 06:09:19 +08:00
|
|
|
template <class Alloc> stack(const stack& c, const Alloc& a);
|
2010-05-12 03:42:16 +08:00
|
|
|
template <class Alloc> stack(stack&& c, const Alloc& a);
|
2022-01-06 19:36:07 +08:00
|
|
|
template<class InputIterator, class Alloc>
|
|
|
|
stack(InputIterator first, InputIterator last, const Alloc&); // since C++23
|
2010-05-12 03:42:16 +08:00
|
|
|
|
|
|
|
bool empty() const;
|
|
|
|
size_type size() const;
|
|
|
|
reference top();
|
|
|
|
const_reference top() const;
|
|
|
|
|
|
|
|
void push(const value_type& x);
|
|
|
|
void push(value_type&& x);
|
2017-01-25 07:09:12 +08:00
|
|
|
template <class... Args> reference emplace(Args&&... args); // reference in C++17
|
2010-05-12 03:42:16 +08:00
|
|
|
void pop();
|
|
|
|
|
2016-04-22 07:38:59 +08:00
|
|
|
void swap(stack& c) noexcept(is_nothrow_swappable_v<Container>)
|
2010-05-12 03:42:16 +08:00
|
|
|
};
|
|
|
|
|
2018-05-22 09:57:53 +08:00
|
|
|
template<class Container>
|
|
|
|
stack(Container) -> stack<typename Container::value_type, Container>; // C++17
|
2019-05-30 00:01:36 +08:00
|
|
|
|
2022-01-06 19:36:07 +08:00
|
|
|
template<class InputIterator>
|
|
|
|
stack(InputIterator, InputIterator) -> stack<iter-value-type<InputIterator>>; // since C++23
|
|
|
|
|
2019-05-30 00:01:36 +08:00
|
|
|
template<class Container, class Allocator>
|
2018-05-22 09:57:53 +08:00
|
|
|
stack(Container, Allocator) -> stack<typename Container::value_type, Container>; // C++17
|
|
|
|
|
2022-01-06 19:36:07 +08:00
|
|
|
template<class InputIterator, class Allocator>
|
|
|
|
stack(InputIterator, InputIterator, Allocator)
|
|
|
|
-> stack<iter-value-type<InputIterator>,
|
|
|
|
deque<iter-value-type<InputIterator>, Allocator>>; // since C++23
|
|
|
|
|
2010-05-12 03:42:16 +08:00
|
|
|
template <class T, class Container>
|
|
|
|
bool operator==(const stack<T, Container>& x, const stack<T, Container>& y);
|
|
|
|
template <class T, class Container>
|
|
|
|
bool operator< (const stack<T, Container>& x, const stack<T, Container>& y);
|
|
|
|
template <class T, class Container>
|
|
|
|
bool operator!=(const stack<T, Container>& x, const stack<T, Container>& y);
|
|
|
|
template <class T, class Container>
|
|
|
|
bool operator> (const stack<T, Container>& x, const stack<T, Container>& y);
|
|
|
|
template <class T, class Container>
|
|
|
|
bool operator>=(const stack<T, Container>& x, const stack<T, Container>& y);
|
|
|
|
template <class T, class Container>
|
|
|
|
bool operator<=(const stack<T, Container>& x, const stack<T, Container>& y);
|
|
|
|
|
|
|
|
template <class T, class Container>
|
2011-06-05 06:09:19 +08:00
|
|
|
void swap(stack<T, Container>& x, stack<T, Container>& y)
|
|
|
|
noexcept(noexcept(x.swap(y)));
|
2010-05-12 03:42:16 +08:00
|
|
|
|
|
|
|
} // std
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <__config>
|
2022-01-06 19:36:07 +08:00
|
|
|
#include <__iterator/iterator_traits.h>
|
2021-07-01 21:25:35 +08:00
|
|
|
#include <__memory/uses_allocator.h>
|
2021-06-05 10:47:47 +08:00
|
|
|
#include <__utility/forward.h>
|
2010-05-12 03:42:16 +08:00
|
|
|
#include <deque>
|
2022-01-06 19:36:07 +08:00
|
|
|
#include <type_traits>
|
2021-12-23 01:14:14 +08:00
|
|
|
#include <version>
|
2010-05-12 03:42:16 +08:00
|
|
|
|
2011-10-18 04:05:10 +08:00
|
|
|
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
2022-02-02 09:16:40 +08:00
|
|
|
# pragma GCC system_header
|
2011-10-18 04:05:10 +08:00
|
|
|
#endif
|
2010-05-12 03:42:16 +08:00
|
|
|
|
|
|
|
_LIBCPP_BEGIN_NAMESPACE_STD
|
|
|
|
|
2017-01-05 07:56:00 +08:00
|
|
|
template <class _Tp, class _Container = deque<_Tp> > class _LIBCPP_TEMPLATE_VIS stack;
|
2010-05-12 03:42:16 +08:00
|
|
|
|
|
|
|
template <class _Tp, class _Container>
|
2012-09-14 08:39:16 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-12 03:42:16 +08:00
|
|
|
bool
|
|
|
|
operator==(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y);
|
|
|
|
|
|
|
|
template <class _Tp, class _Container>
|
2012-09-14 08:39:16 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-12 03:42:16 +08:00
|
|
|
bool
|
|
|
|
operator< (const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y);
|
|
|
|
|
2015-02-19 01:51:56 +08:00
|
|
|
template <class _Tp, class _Container /*= deque<_Tp>*/>
|
2017-01-05 07:56:00 +08:00
|
|
|
class _LIBCPP_TEMPLATE_VIS stack
|
2010-05-12 03:42:16 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef _Container container_type;
|
|
|
|
typedef typename container_type::value_type value_type;
|
|
|
|
typedef typename container_type::reference reference;
|
|
|
|
typedef typename container_type::const_reference const_reference;
|
|
|
|
typedef typename container_type::size_type size_type;
|
2016-03-15 01:58:11 +08:00
|
|
|
static_assert((is_same<_Tp, value_type>::value), "" );
|
2019-05-30 00:01:36 +08:00
|
|
|
|
2010-05-12 03:42:16 +08:00
|
|
|
protected:
|
|
|
|
container_type c;
|
|
|
|
|
|
|
|
public:
|
2010-09-24 01:31:07 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2011-06-05 06:09:19 +08:00
|
|
|
stack()
|
|
|
|
_NOEXCEPT_(is_nothrow_default_constructible<container_type>::value)
|
|
|
|
: c() {}
|
|
|
|
|
2010-09-24 01:31:07 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2011-06-05 06:09:19 +08:00
|
|
|
stack(const stack& __q) : c(__q.c) {}
|
|
|
|
|
2017-04-19 05:16:26 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
|
|
stack& operator=(const stack& __q) {c = __q.c; return *this;}
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef _LIBCPP_CXX03_LANG
|
2010-09-24 01:31:07 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2011-06-05 06:09:19 +08:00
|
|
|
stack(stack&& __q)
|
|
|
|
_NOEXCEPT_(is_nothrow_move_constructible<container_type>::value)
|
2011-07-01 05:18:19 +08:00
|
|
|
: c(_VSTD::move(__q.c)) {}
|
2011-06-05 06:09:19 +08:00
|
|
|
|
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
|
|
stack& operator=(stack&& __q)
|
|
|
|
_NOEXCEPT_(is_nothrow_move_assignable<container_type>::value)
|
2011-07-01 05:18:19 +08:00
|
|
|
{c = _VSTD::move(__q.c); return *this;}
|
2011-06-05 06:09:19 +08:00
|
|
|
|
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2011-07-01 05:18:19 +08:00
|
|
|
explicit stack(container_type&& __c) : c(_VSTD::move(__c)) {}
|
2021-04-21 00:03:32 +08:00
|
|
|
#endif // _LIBCPP_CXX03_LANG
|
2017-04-19 05:16:26 +08:00
|
|
|
|
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
|
|
explicit stack(const container_type& __c) : c(__c) {}
|
|
|
|
|
2010-05-12 03:42:16 +08:00
|
|
|
template <class _Alloc>
|
2010-09-24 01:31:07 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-12 03:42:16 +08:00
|
|
|
explicit stack(const _Alloc& __a,
|
2021-09-08 21:14:43 +08:00
|
|
|
__enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0)
|
2010-05-12 03:42:16 +08:00
|
|
|
: c(__a) {}
|
|
|
|
template <class _Alloc>
|
2010-09-24 01:31:07 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-12 03:42:16 +08:00
|
|
|
stack(const container_type& __c, const _Alloc& __a,
|
2021-09-08 21:14:43 +08:00
|
|
|
__enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0)
|
2010-05-12 03:42:16 +08:00
|
|
|
: c(__c, __a) {}
|
|
|
|
template <class _Alloc>
|
2010-09-24 01:31:07 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-12 03:42:16 +08:00
|
|
|
stack(const stack& __s, const _Alloc& __a,
|
2021-09-08 21:14:43 +08:00
|
|
|
__enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0)
|
2010-05-12 03:42:16 +08:00
|
|
|
: c(__s.c, __a) {}
|
2017-04-19 05:16:26 +08:00
|
|
|
#ifndef _LIBCPP_CXX03_LANG
|
2010-05-12 03:42:16 +08:00
|
|
|
template <class _Alloc>
|
2010-09-24 01:31:07 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-12 03:42:16 +08:00
|
|
|
stack(container_type&& __c, const _Alloc& __a,
|
2021-09-08 21:14:43 +08:00
|
|
|
__enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0)
|
2011-07-01 05:18:19 +08:00
|
|
|
: c(_VSTD::move(__c), __a) {}
|
2010-05-12 03:42:16 +08:00
|
|
|
template <class _Alloc>
|
2010-09-24 01:31:07 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-12 03:42:16 +08:00
|
|
|
stack(stack&& __s, const _Alloc& __a,
|
2021-09-08 21:14:43 +08:00
|
|
|
__enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0)
|
2011-07-01 05:18:19 +08:00
|
|
|
: c(_VSTD::move(__s.c), __a) {}
|
2021-04-21 00:03:32 +08:00
|
|
|
#endif // _LIBCPP_CXX03_LANG
|
2010-05-12 03:42:16 +08:00
|
|
|
|
2022-01-06 19:36:07 +08:00
|
|
|
#if _LIBCPP_STD_VER > 20
|
|
|
|
template <class _InputIterator,
|
|
|
|
class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>>
|
|
|
|
_LIBCPP_HIDE_FROM_ABI
|
|
|
|
stack(_InputIterator __first, _InputIterator __last) : c(__first, __last) {}
|
|
|
|
|
|
|
|
template <class _InputIterator,
|
|
|
|
class _Alloc,
|
|
|
|
class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
|
|
|
|
class = __enable_if_t<uses_allocator<container_type, _Alloc>::value>>
|
|
|
|
_LIBCPP_HIDE_FROM_ABI
|
|
|
|
stack(_InputIterator __first, _InputIterator __last, const _Alloc& __alloc) : c(__first, __last, __alloc) {}
|
|
|
|
#endif
|
|
|
|
|
2017-11-15 13:51:26 +08:00
|
|
|
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
|
2010-05-12 03:42:16 +08:00
|
|
|
bool empty() const {return c.empty();}
|
2010-09-24 01:31:07 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-12 03:42:16 +08:00
|
|
|
size_type size() const {return c.size();}
|
2010-09-24 01:31:07 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-12 03:42:16 +08:00
|
|
|
reference top() {return c.back();}
|
2010-09-24 01:31:07 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-12 03:42:16 +08:00
|
|
|
const_reference top() const {return c.back();}
|
|
|
|
|
2010-09-24 01:31:07 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-12 03:42:16 +08:00
|
|
|
void push(const value_type& __v) {c.push_back(__v);}
|
2017-04-19 05:16:26 +08:00
|
|
|
#ifndef _LIBCPP_CXX03_LANG
|
2010-09-24 01:31:07 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2011-07-01 05:18:19 +08:00
|
|
|
void push(value_type&& __v) {c.push_back(_VSTD::move(__v));}
|
2017-04-19 05:16:26 +08:00
|
|
|
|
2010-09-24 01:31:07 +08:00
|
|
|
template <class... _Args>
|
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2017-01-25 07:09:12 +08:00
|
|
|
#if _LIBCPP_STD_VER > 14
|
2018-01-25 06:42:25 +08:00
|
|
|
decltype(auto) emplace(_Args&&... __args)
|
2016-07-21 11:20:17 +08:00
|
|
|
{ return c.emplace_back(_VSTD::forward<_Args>(__args)...);}
|
2017-01-25 07:09:12 +08:00
|
|
|
#else
|
|
|
|
void emplace(_Args&&... __args)
|
|
|
|
{ c.emplace_back(_VSTD::forward<_Args>(__args)...);}
|
|
|
|
#endif
|
2021-04-21 00:03:32 +08:00
|
|
|
#endif // _LIBCPP_CXX03_LANG
|
2017-04-19 05:16:26 +08:00
|
|
|
|
2010-09-24 01:31:07 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-12 03:42:16 +08:00
|
|
|
void pop() {c.pop_back();}
|
|
|
|
|
2010-09-24 01:31:07 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-12 03:42:16 +08:00
|
|
|
void swap(stack& __s)
|
2011-06-05 06:09:19 +08:00
|
|
|
_NOEXCEPT_(__is_nothrow_swappable<container_type>::value)
|
2010-05-12 03:42:16 +08:00
|
|
|
{
|
2011-07-01 05:18:19 +08:00
|
|
|
using _VSTD::swap;
|
2010-05-12 03:42:16 +08:00
|
|
|
swap(c, __s.c);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class T1, class _C1>
|
|
|
|
friend
|
|
|
|
bool
|
|
|
|
operator==(const stack<T1, _C1>& __x, const stack<T1, _C1>& __y);
|
2010-08-22 08:02:43 +08:00
|
|
|
|
2010-05-12 03:42:16 +08:00
|
|
|
template <class T1, class _C1>
|
|
|
|
friend
|
|
|
|
bool
|
|
|
|
operator< (const stack<T1, _C1>& __x, const stack<T1, _C1>& __y);
|
|
|
|
};
|
|
|
|
|
2022-01-06 19:36:07 +08:00
|
|
|
#if _LIBCPP_STD_VER > 14
|
2018-05-22 09:57:53 +08:00
|
|
|
template<class _Container,
|
[libc++] Use enable_if_t instead of _EnableIf
I just ran into a compiler error involving __bind_back and some overloads
that were being disabled with _EnableIf. I noticed that the error message
was quite bad and did not mention the reason for the overload being
excluded. Specifically, the error looked like this:
candidate template ignored: substitution failure [with _Args =
<ContiguousView>]: no member named '_EnableIfImpl' in 'std::_MetaBase<false>'
Instead, when using enable_if or enable_if_t, the compiler is clever and
can produce better diagnostics, like so:
candidate template ignored: requirement 'is_invocable_v<
std::__bind_back_op<1, std::integer_sequence<unsigned long, 0>>,
std::ranges::views::__transform::__fn &, std::tuple<PlusOne> &,
ContiguousView>' was not satisfied [with _Args = <ContiguousView>]
Basically, it tries to do a poor man's implementation of concepts, which
is already a lot better than simply complaining about substitution failure.
Hence, this commit uses enable_if_t instead of _EnableIf whenever
possible. That is both more straightforward than using the internal
helper, and also leads to better error messages in those cases.
I understand the motivation for _EnableIf's implementation was to improve
compile-time performance, however I believe striving to improve error
messages is even more important for our QOI, hence this patch. Furthermore,
it is unclear that _EnableIf actually improved compile-time performance
in any noticeable way (see discussion in the review for details).
Differential Revision: https://reviews.llvm.org/D108216
2021-08-18 00:26:09 +08:00
|
|
|
class = enable_if_t<!__is_allocator<_Container>::value>
|
2018-05-22 09:57:53 +08:00
|
|
|
>
|
|
|
|
stack(_Container)
|
|
|
|
-> stack<typename _Container::value_type, _Container>;
|
2019-05-30 00:01:36 +08:00
|
|
|
|
2018-05-22 09:57:53 +08:00
|
|
|
template<class _Container,
|
|
|
|
class _Alloc,
|
[libc++] Use enable_if_t instead of _EnableIf
I just ran into a compiler error involving __bind_back and some overloads
that were being disabled with _EnableIf. I noticed that the error message
was quite bad and did not mention the reason for the overload being
excluded. Specifically, the error looked like this:
candidate template ignored: substitution failure [with _Args =
<ContiguousView>]: no member named '_EnableIfImpl' in 'std::_MetaBase<false>'
Instead, when using enable_if or enable_if_t, the compiler is clever and
can produce better diagnostics, like so:
candidate template ignored: requirement 'is_invocable_v<
std::__bind_back_op<1, std::integer_sequence<unsigned long, 0>>,
std::ranges::views::__transform::__fn &, std::tuple<PlusOne> &,
ContiguousView>' was not satisfied [with _Args = <ContiguousView>]
Basically, it tries to do a poor man's implementation of concepts, which
is already a lot better than simply complaining about substitution failure.
Hence, this commit uses enable_if_t instead of _EnableIf whenever
possible. That is both more straightforward than using the internal
helper, and also leads to better error messages in those cases.
I understand the motivation for _EnableIf's implementation was to improve
compile-time performance, however I believe striving to improve error
messages is even more important for our QOI, hence this patch. Furthermore,
it is unclear that _EnableIf actually improved compile-time performance
in any noticeable way (see discussion in the review for details).
Differential Revision: https://reviews.llvm.org/D108216
2021-08-18 00:26:09 +08:00
|
|
|
class = enable_if_t<!__is_allocator<_Container>::value>,
|
|
|
|
class = enable_if_t<uses_allocator<_Container, _Alloc>::value>
|
2019-05-30 00:01:36 +08:00
|
|
|
>
|
2018-05-22 09:57:53 +08:00
|
|
|
stack(_Container, _Alloc)
|
|
|
|
-> stack<typename _Container::value_type, _Container>;
|
|
|
|
#endif
|
|
|
|
|
2022-01-06 19:36:07 +08:00
|
|
|
#if _LIBCPP_STD_VER > 20
|
|
|
|
template<class _InputIterator,
|
|
|
|
class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>>
|
|
|
|
stack(_InputIterator, _InputIterator)
|
|
|
|
-> stack<__iter_value_type<_InputIterator>>;
|
|
|
|
|
|
|
|
template<class _InputIterator,
|
|
|
|
class _Alloc,
|
|
|
|
class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
|
|
|
|
class = __enable_if_t<__is_allocator<_Alloc>::value>>
|
|
|
|
stack(_InputIterator, _InputIterator, _Alloc)
|
|
|
|
-> stack<__iter_value_type<_InputIterator>, deque<__iter_value_type<_InputIterator>, _Alloc>>;
|
|
|
|
#endif
|
|
|
|
|
2010-05-12 03:42:16 +08:00
|
|
|
template <class _Tp, class _Container>
|
2010-09-24 01:31:07 +08:00
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
2010-05-12 03:42:16 +08:00
|
|
|
bool
|
|
|
|
operator==(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y)
|
|
|
|
{
|
|
|
|
return __x.c == __y.c;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class _Tp, class _Container>
|
2010-09-24 01:31:07 +08:00
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
2010-05-12 03:42:16 +08:00
|
|
|
bool
|
|
|
|
operator< (const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y)
|
|
|
|
{
|
|
|
|
return __x.c < __y.c;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class _Tp, class _Container>
|
2010-09-24 01:31:07 +08:00
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
2010-05-12 03:42:16 +08:00
|
|
|
bool
|
|
|
|
operator!=(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y)
|
|
|
|
{
|
|
|
|
return !(__x == __y);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class _Tp, class _Container>
|
2010-09-24 01:31:07 +08:00
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
2010-05-12 03:42:16 +08:00
|
|
|
bool
|
|
|
|
operator> (const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y)
|
|
|
|
{
|
|
|
|
return __y < __x;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class _Tp, class _Container>
|
2010-09-24 01:31:07 +08:00
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
2010-05-12 03:42:16 +08:00
|
|
|
bool
|
|
|
|
operator>=(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y)
|
|
|
|
{
|
|
|
|
return !(__x < __y);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class _Tp, class _Container>
|
2010-09-24 01:31:07 +08:00
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
2010-05-12 03:42:16 +08:00
|
|
|
bool
|
|
|
|
operator<=(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y)
|
|
|
|
{
|
|
|
|
return !(__y < __x);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class _Tp, class _Container>
|
2010-09-24 01:31:07 +08:00
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
2021-09-08 21:14:43 +08:00
|
|
|
__enable_if_t<__is_swappable<_Container>::value, void>
|
2010-05-12 03:42:16 +08:00
|
|
|
swap(stack<_Tp, _Container>& __x, stack<_Tp, _Container>& __y)
|
2011-06-05 06:09:19 +08:00
|
|
|
_NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
|
2010-05-12 03:42:16 +08:00
|
|
|
{
|
|
|
|
__x.swap(__y);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class _Tp, class _Container, class _Alloc>
|
2017-01-05 07:56:00 +08:00
|
|
|
struct _LIBCPP_TEMPLATE_VIS uses_allocator<stack<_Tp, _Container>, _Alloc>
|
2010-05-12 03:42:16 +08:00
|
|
|
: public uses_allocator<_Container, _Alloc>
|
|
|
|
{
|
|
|
|
};
|
|
|
|
|
|
|
|
_LIBCPP_END_NAMESPACE_STD
|
|
|
|
|
2021-04-21 00:03:32 +08:00
|
|
|
#endif // _LIBCPP_STACK
|