4#ifndef TETL_STACK_STACK_HPP
5#define TETL_STACK_STACK_HPP
7#include <etl/_iterator/begin.hpp>
8#include <etl/_iterator/data.hpp>
9#include <etl/_iterator/end.hpp>
10#include <etl/_iterator/rbegin.hpp>
11#include <etl/_iterator/rend.hpp>
12#include <etl/_iterator/size.hpp>
13#include <etl/_type_traits/declval.hpp>
14#include <etl/_type_traits/is_nothrow_swappable.hpp>
15#include <etl/_type_traits/is_swappable.hpp>
16#include <etl/_utility/forward.hpp>
17#include <etl/_utility/move.hpp>
31template <
typename T,
typename Container>
33 using value_type =
typename Container::value_type;
34 using reference =
typename Container::reference;
35 using const_reference =
typename Container::const_reference;
36 using size_type =
typename Container::size_type;
37 using container_type = Container;
47 constexpr explicit stack(Container
const& cont)
53 constexpr explicit stack(Container&& cont)
101 c.push_back(
etl::move(x));
108 template <
typename... Args>
113 return c.emplace_back(
etl::forward<Args>(args)...);
137 return lhs.c == rhs.c;
147 return lhs.c != rhs.c;
157 return lhs.c < rhs.c;
167 return lhs.c <= rhs.c;
177 return lhs.c > rhs.c;
187 return lhs.c >= rhs.c;
196template <
typename Container>
202template <
typename T,
typename C>
203 requires(is_swappable_v<C>)
Definition adjacent_find.hpp:9
constexpr auto swap(stack< T, C > &lhs, stack< T, C > &rhs) noexcept(noexcept(lhs.swap(rhs))) -> void
Specializes the swap algorithm for stack. Swaps the contents of lhs and rhs. This overload only parti...
Definition stack.hpp:204
stack(Container) -> stack< typename Container::value_type, Container >
The stack class is a container adapter that gives the programmer the functionality of a stack - speci...
Definition stack.hpp:32
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:124
friend constexpr auto operator>=(stack const &lhs, stack const &rhs) noexcept(noexcept(declval< Container >() >=declval< Container >())) -> bool
Compares the contents of the underlying containers of two container adaptors. The comparison is done ...
Definition stack.hpp:184
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:110
Container c
Definition stack.hpp:191
friend constexpr auto operator==(stack const &lhs, stack const &rhs) noexcept(noexcept(declval< Container >()==declval< Container >())) -> bool
Compares the contents of the underlying containers of two container adaptors. The comparison is done ...
Definition stack.hpp:134
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:79
constexpr stack(Container &&cont)
Move-constructs the underlying container c with cont .
Definition stack.hpp:53
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:65
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:93
friend constexpr auto operator<=(stack const &lhs, stack const &rhs) noexcept(noexcept(declval< Container >()<=declval< Container >())) -> bool
Compares the contents of the underlying containers of two container adaptors. The comparison is done ...
Definition stack.hpp:164
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:87
constexpr auto pop() noexcept(noexcept(declval< Container >().pop_back())) -> void
Removes the top element from the stack.
Definition stack.hpp:117
constexpr stack()
Default constructor. Value-initializes the container.
Definition stack.hpp:40
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:99
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:47
friend constexpr auto operator<(stack const &lhs, stack const &rhs) noexcept(noexcept(declval< Container >()< declval< Container >())) -> bool
Compares the contents of the underlying containers of two container adaptors. The comparison is done ...
Definition stack.hpp:154
friend constexpr auto operator>(stack const &lhs, stack const &rhs) noexcept(noexcept(declval< Container >() > declval< Container >())) -> bool
Compares the contents of the underlying containers of two container adaptors. The comparison is done ...
Definition stack.hpp:174
friend constexpr auto operator!=(stack const &lhs, stack const &rhs) noexcept(noexcept(declval< Container >() !=declval< Container >())) -> bool
Compares the contents of the underlying containers of two container adaptors. The comparison is done ...
Definition stack.hpp:144
constexpr auto size() const noexcept(noexcept(declval< Container >().size())) -> size_type
Returns the number of elements in the underlying container.
Definition stack.hpp:71