A C++ template library for embedded applications
Designed and maintained by
Aster Consulting Ltd

stack

A fixed capacity stack.
STL equivalent: std::stack

etl::stack<typename T, const size_t SIZE>

Inherits from etl::istack<T>
etl::istack may be used as a size independent pointer or reference type for any etl::stack instance.

Member types

value_type T
size_type  std::size_t

Constructor

etl::stack<typename T, const size_t SIZE>();
Default constructs SIZE elements.

Element access

T& top()
const T& top() const
Returns a reference or const reference to the element at the top of the stack.

Capacity

bool empty() const
Returns true if the size of the stack is zero, otherwise false.

bool full() const
Returns true if the size of the stack is SIZE, otherwise false.

size_t size() const
Returns the size of the stack.

size_t available() const
Returns the remaining available capacity in the stack.

size_t max_size() const
Returns the maximum possible size of the stack.

size_t capacity() const
Returns the maximum possible size of the stack.

Modifiers

void push(parameter_t value);
void push();
Pushes a value to the top of the stack. The first pushes a value, the second allocates the new element but does not
initialise it.
Emits an etl::stack_full if the stack is full and ETL_CHECK_PUSH_POP is defined.

void emplace(const T1& value1);
void emplace(const T1& value1, const T2& value2);
void emplace(const T1& value1, const T2& value2, const T3& value3);
void emplace(const T1& value1, const T2& value2, const T3& value3, const T4& value4);
Constructs an item in the the stack 'in place'.
Supports up to four constructor parameters.


void pop();
Pop a value from the top of the stack.
Emits an etl::stack_empty if the stack is empty and ETL_CHECK_PUSH_POP is defined.

void clear();
Clears the stack to a size of zero.
stack.h