3#ifndef TETL_STACK_STACK_HPP
4#define TETL_STACK_STACK_HPP
30template <
typename T,
typename Container>
46 constexpr explicit stack(Container
const& cont)
52 constexpr explicit stack(Container&& cont)
64 [[nodiscard]]
constexpr auto empty() const noexcept(noexcept(
declval<Container>().
empty())) ->
bool
78 [[nodiscard]]
constexpr auto top() noexcept(noexcept(
declval<Container>().back())) ->
reference {
return c.back(); }
104 template <
typename... Args>
112 constexpr auto pop() noexcept(noexcept(
declval<Container>().pop_back())) ->
void {
c.pop_back(); }
126 noexcept(
noexcept(lhs.c == rhs.c)) ->
bool
128 return lhs.c == rhs.c;
135 noexcept(
noexcept(lhs.c != rhs.c)) ->
bool
137 return lhs.c != rhs.c;
143 [[nodiscard]]
friend constexpr auto operator<(
stack const& lhs,
stack const& rhs)
noexcept(
noexcept(lhs.c < rhs.c))
146 return lhs.c < rhs.c;
153 noexcept(
noexcept(lhs.c <= rhs.c)) ->
bool
155 return lhs.c <= rhs.c;
161 [[nodiscard]]
friend constexpr auto operator>(
stack const& lhs,
stack const& rhs)
noexcept(
noexcept(lhs.c > rhs.c))
164 return lhs.c > rhs.c;
171 noexcept(
noexcept(lhs.c >= rhs.c)) ->
bool
173 return lhs.c >= rhs.c;
182template <
typename Container>
188template <
typename T,
typename C>
constexpr auto move(InputIt first, InputIt last, OutputIt destination) -> OutputIt
Moves the elements in the range [first, last), to another range beginning at destination,...
Definition move.hpp:26
Definition adjacent_find.hpp:8
auto declval() noexcept -> add_rvalue_reference_t< T >
constexpr bool is_swappable_v
Definition is_swappable.hpp:21
stack(Container) -> stack< typename Container::value_type, Container >
auto swap(inplace_function< R(Args...), Capacity, Alignment > &lhs, inplace_function< R(Args...), Capacity, Alignment > &rhs) noexcept -> void
Overloads the etl::swap algorithm for etl::inplace_function. Exchanges the state of lhs with that of ...
Definition inplace_function.hpp:249
constexpr auto forward(remove_reference_t< T > ¶m) noexcept -> T &&
Forwards lvalues as either lvalues or as rvalues, depending on T. When t is a forwarding reference (a...
Definition forward.hpp:18
constexpr bool is_nothrow_swappable_v
Definition is_nothrow_swappable.hpp:19
The stack class is a container adapter that gives the programmer the functionality of a stack - speci...
Definition stack.hpp:31
constexpr auto swap(stack &s) noexcept(is_nothrow_swappable_v< Container >) -> void
Exchanges the contents of the container adaptor with those of other.
Definition stack.hpp:116
friend constexpr auto operator<=(stack const &lhs, stack const &rhs) noexcept(noexcept(lhs.c<=rhs.c)) -> bool
Compares the contents of the underlying containers of two container adaptors. The comparison is done ...
Definition stack.hpp:152
typename Container::const_reference const_reference
Definition stack.hpp:34
constexpr auto emplace(Args &&... args) noexcept(noexcept(declval< Container >().emplace_back(etl::forward< Args >(args)...))) -> decltype(auto)
Pushes a new element on top of the stack. The element is constructed in-place, i.e....
Definition stack.hpp:105
friend constexpr auto operator==(stack const &lhs, stack const &rhs) noexcept(noexcept(lhs.c==rhs.c)) -> bool
Compares the contents of the underlying containers of two container adaptors. The comparison is done ...
Definition stack.hpp:125
Container c
Definition stack.hpp:177
friend constexpr auto operator>(stack const &lhs, stack const &rhs) noexcept(noexcept(lhs.c > rhs.c)) -> bool
Compares the contents of the underlying containers of two container adaptors. The comparison is done ...
Definition stack.hpp:161
constexpr auto top() noexcept(noexcept(declval< Container >().back())) -> reference
Returns reference to the top element in the stack. This is the most recently pushed element....
Definition stack.hpp:78
constexpr stack(Container &&cont)
Move-constructs the underlying container c with cont .
Definition stack.hpp:52
typename Container::reference reference
Definition stack.hpp:33
typename Container::size_type size_type
Definition stack.hpp:35
friend constexpr auto operator>=(stack const &lhs, stack const &rhs) noexcept(noexcept(lhs.c >=rhs.c)) -> bool
Compares the contents of the underlying containers of two container adaptors. The comparison is done ...
Definition stack.hpp:170
constexpr stack(stack const &other)=default
Copy constructor.
constexpr auto empty() const noexcept(noexcept(declval< Container >().empty())) -> bool
Checks if the underlying container has no elements.
Definition stack.hpp:64
friend constexpr auto operator!=(stack const &lhs, stack const &rhs) noexcept(noexcept(lhs.c !=rhs.c)) -> bool
Compares the contents of the underlying containers of two container adaptors. The comparison is done ...
Definition stack.hpp:134
constexpr auto push(value_type const &x) noexcept(noexcept(declval< Container >().push_back(x))) -> void
Pushes the given element value to the top of the stack.
Definition stack.hpp:89
constexpr auto top() const noexcept(noexcept(declval< Container >().back())) -> const_reference
Returns reference to the top element in the stack. This is the most recently pushed element....
Definition stack.hpp:83
constexpr auto pop() noexcept(noexcept(declval< Container >().pop_back())) -> void
Removes the top element from the stack.
Definition stack.hpp:112
typename Container::value_type value_type
Definition stack.hpp:32
Container container_type
Definition stack.hpp:36
constexpr stack()
Default constructor. Value-initializes the container.
Definition stack.hpp:39
friend constexpr auto operator<(stack const &lhs, stack const &rhs) noexcept(noexcept(lhs.c< rhs.c)) -> bool
Compares the contents of the underlying containers of two container adaptors. The comparison is done ...
Definition stack.hpp:143
constexpr auto push(value_type &&x) noexcept(noexcept(declval< Container >().push_back(etl::move(x)))) -> void
Pushes the given element value to the top of the stack.
Definition stack.hpp:95
constexpr stack(stack &&other) noexcept=default
Move constructor.
constexpr stack(Container const &cont)
Copy-constructs the underlying container c with the contents of cont.
Definition stack.hpp:46
constexpr auto size() const noexcept(noexcept(declval< Container >().size())) -> size_type
Returns the number of elements in the underlying container.
Definition stack.hpp:70