tetl 0.1.0
Embedded Template Library
|
The stack class is a container adapter that gives the programmer the functionality of a stack - specifically, a LIFO (last-in, first-out) data structure. More...
#include <stack.hpp>
Public Types | |
using | const_reference = typename Container::const_reference |
using | container_type = Container |
using | reference = typename Container::reference |
using | size_type = typename Container::size_type |
using | value_type = typename Container::value_type |
Public Member Functions | |
constexpr | stack () |
Default constructor. Value-initializes the container. | |
constexpr | stack (Container &&cont) |
Move-constructs the underlying container c with cont . | |
constexpr | stack (Container const &cont) |
Copy-constructs the underlying container c with the contents of cont. | |
constexpr | stack (stack &&other) noexcept=default |
Move constructor. | |
constexpr | stack (stack const &other)=default |
Copy constructor. | |
template<typename... Args> | |
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. no copy or move operations are performed. The constructor of the element is called with exactly the same arguments as supplied to the function. | |
constexpr auto | empty () const noexcept(noexcept(declval< Container >().empty())) -> bool |
Checks if the underlying container has no elements. | |
constexpr auto | pop () noexcept(noexcept(declval< Container >().pop_back())) -> void |
Removes the top element from the stack. | |
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. | |
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. | |
constexpr auto | size () const noexcept(noexcept(declval< Container >().size())) -> size_type |
Returns the number of elements in the underlying container. | |
constexpr auto | swap (stack &s) noexcept(is_nothrow_swappable_v< Container >) -> void |
Exchanges the contents of the container adaptor with those of other. | |
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. This element will be removed on a call to pop(). | |
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. This element will be removed on a call to pop(). | |
Protected Attributes | |
Container | c |
Friends | |
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 by applying the corresponding operator to the underlying containers. | |
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 by applying the corresponding operator to the underlying containers. | |
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 by applying the corresponding operator to the underlying containers. | |
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 by applying the corresponding operator to the underlying containers. | |
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 by applying the corresponding operator to the underlying containers. | |
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 by applying the corresponding operator to the underlying containers. | |
The stack class is a container adapter that gives the programmer the functionality of a stack - specifically, a LIFO (last-in, first-out) data structure.
The class template acts as a wrapper to the underlying container - only a specific set of functions is provided. The stack pushes and pops the element from the back of the underlying container, known as the top of the stack.
using const_reference = typename Container::const_reference |
Default constructor. Value-initializes the container.
Copy-constructs the underlying container c with the contents of cont.
Move-constructs the underlying container c with cont .
|
inlineconstexprnoexcept |
Pushes a new element on top of the stack. The element is constructed in-place, i.e. no copy or move operations are performed. The constructor of the element is called with exactly the same arguments as supplied to the function.
Checks if the underlying container has no elements.
Removes the top element from the stack.
|
inlineconstexprnoexcept |
Pushes the given element value to the top of the stack.
|
inlineconstexprnoexcept |
Pushes the given element value to the top of the stack.
Returns the number of elements in the underlying container.
Exchanges the contents of the container adaptor with those of other.
|
inlineconstexprnoexcept |
Returns reference to the top element in the stack. This is the most recently pushed element. This element will be removed on a call to pop().
Returns reference to the top element in the stack. This is the most recently pushed element. This element will be removed on a call to pop().
|
friend |
Compares the contents of the underlying containers of two container adaptors. The comparison is done by applying the corresponding operator to the underlying containers.
|
friend |
Compares the contents of the underlying containers of two container adaptors. The comparison is done by applying the corresponding operator to the underlying containers.
|
friend |
Compares the contents of the underlying containers of two container adaptors. The comparison is done by applying the corresponding operator to the underlying containers.
|
friend |
Compares the contents of the underlying containers of two container adaptors. The comparison is done by applying the corresponding operator to the underlying containers.
|
friend |
Compares the contents of the underlying containers of two container adaptors. The comparison is done by applying the corresponding operator to the underlying containers.
|
friend |
Compares the contents of the underlying containers of two container adaptors. The comparison is done by applying the corresponding operator to the underlying containers.