tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
stack< T, Container > Struct Template Reference

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(lhs.c !=rhs.c)) -> 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(lhs.c< rhs.c)) -> 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(lhs.c<=rhs.c)) -> 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(lhs.c==rhs.c)) -> 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(lhs.c > rhs.c)) -> 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(lhs.c >=rhs.c)) -> 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.
 

Detailed Description

template<typename T, typename Container>
struct etl::stack< T, Container >

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.

Member Typedef Documentation

◆ const_reference

template<typename T, typename Container>
using const_reference = typename Container::const_reference

◆ container_type

template<typename T, typename Container>
using container_type = Container

◆ reference

template<typename T, typename Container>
using reference = typename Container::reference

◆ size_type

template<typename T, typename Container>
using size_type = typename Container::size_type

◆ value_type

template<typename T, typename Container>
using value_type = typename Container::value_type

Constructor & Destructor Documentation

◆ stack() [1/5]

template<typename T, typename Container>
stack ( )
inlineconstexpr

Default constructor. Value-initializes the container.

◆ stack() [2/5]

template<typename T, typename Container>
stack ( Container const & cont)
inlineexplicitconstexpr

Copy-constructs the underlying container c with the contents of cont.

◆ stack() [3/5]

template<typename T, typename Container>
stack ( Container && cont)
inlineexplicitconstexpr

Move-constructs the underlying container c with cont .

◆ stack() [4/5]

template<typename T, typename Container>
stack ( stack< T, Container > const & other)
constexprdefault

Copy constructor.

◆ stack() [5/5]

template<typename T, typename Container>
stack ( stack< T, Container > && other)
constexprdefaultnoexcept

Move constructor.

Member Function Documentation

◆ emplace()

template<typename T, typename Container>
template<typename... Args>
auto emplace ( Args &&... args) -> decltype(auto)
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.

◆ empty()

template<typename T, typename Container>
auto empty ( ) const -> bool
inlinenodiscardconstexprnoexcept

Checks if the underlying container has no elements.

◆ pop()

template<typename T, typename Container>
auto pop ( ) -> void
inlineconstexprnoexcept

Removes the top element from the stack.

◆ push() [1/2]

template<typename T, typename Container>
auto push ( value_type && x) -> void
inlineconstexprnoexcept

Pushes the given element value to the top of the stack.

◆ push() [2/2]

template<typename T, typename Container>
auto push ( value_type const & x) -> void
inlineconstexprnoexcept

Pushes the given element value to the top of the stack.

◆ size()

template<typename T, typename Container>
auto size ( ) const -> size_type
inlinenodiscardconstexprnoexcept

Returns the number of elements in the underlying container.

◆ swap()

template<typename T, typename Container>
auto swap ( stack< T, Container > & s) -> void
inlineconstexprnoexcept

Exchanges the contents of the container adaptor with those of other.

◆ top() [1/2]

template<typename T, typename Container>
auto top ( ) const -> const_reference
inlinenodiscardconstexprnoexcept

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().

◆ top() [2/2]

template<typename T, typename Container>
auto top ( ) -> reference
inlinenodiscardconstexprnoexcept

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().

Friends And Related Symbol Documentation

◆ operator!=

template<typename T, typename Container>
auto operator!= ( stack< T, Container > const & lhs,
stack< T, Container > const & rhs ) -> bool
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.

◆ operator<

template<typename T, typename Container>
auto operator< ( stack< T, Container > const & lhs,
stack< T, Container > const & rhs ) -> bool
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.

◆ operator<=

template<typename T, typename Container>
auto operator<= ( stack< T, Container > const & lhs,
stack< T, Container > const & rhs ) -> bool
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.

◆ operator==

template<typename T, typename Container>
auto operator== ( stack< T, Container > const & lhs,
stack< T, Container > const & rhs ) -> bool
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.

◆ operator>

template<typename T, typename Container>
auto operator> ( stack< T, Container > const & lhs,
stack< T, Container > const & rhs ) -> bool
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.

◆ operator>=

template<typename T, typename Container>
auto operator>= ( stack< T, Container > const & lhs,
stack< T, Container > const & rhs ) -> bool
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.

Member Data Documentation

◆ c

template<typename T, typename Container>
Container c
protected

The documentation for this struct was generated from the following file: