libpromeki main
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
Stack< T > Class Template Reference

LIFO stack container wrapping std::stack. More...

#include <stack.h>

Public Member Functions

 Stack ()=default
 Default constructor. Creates an empty stack.
 
 Stack (const Stack &other)
 Copy constructor.
 
 Stack (Stack &&other) noexcept
 Move constructor.
 
 ~Stack ()=default
 Destructor.
 
Stackoperator= (const Stack &other)
 Copy assignment operator.
 
Stackoperator= (Stack &&other) noexcept
 Move assignment operator.
 
bool isEmpty () const
 Returns true if the stack has no elements.
 
size_t size () const
 Returns the number of elements.
 
Ttop ()
 Returns a mutable reference to the top element.
 
const Ttop () const
 Returns a const reference to the top element.
 
const TconstTop () const
 Returns a const reference to the top element.
 
void push (const T &value)
 Pushes a value onto the top of the stack.
 
void push (T &&value)
 Pushes a value onto the top of the stack (move overload).
 
T pop ()
 Removes and returns the top element.
 
void clear ()
 Removes all elements.
 
void swap (Stack &other) noexcept
 Swaps contents with another stack.
 

Friends

bool operator== (const Stack &lhs, const Stack &rhs)
 Returns true if both stacks have identical contents.
 
bool operator!= (const Stack &lhs, const Stack &rhs)
 Returns true if the stacks differ.
 

Detailed Description

template<typename T>
class Stack< T >

LIFO stack container wrapping std::stack.

Provides a Qt-inspired API over std::stack with consistent naming conventions matching the rest of libpromeki. Simple value type — no PROMEKI_SHARED_FINAL (not typically shared or iterable).

Template Parameters
TElement type.

Member Function Documentation

◆ pop()

template<typename T >
T Stack< T >::pop ( )
inline

Removes and returns the top element.

Returns
The removed element.

◆ push() [1/2]

template<typename T >
void Stack< T >::push ( const T value)
inline

Pushes a value onto the top of the stack.

Parameters
valueThe value to push.

◆ push() [2/2]

template<typename T >
void Stack< T >::push ( T &&  value)
inline

Pushes a value onto the top of the stack (move overload).

Parameters
valueThe value to move-push.

◆ swap()

template<typename T >
void Stack< T >::swap ( Stack< T > &  other)
inlinenoexcept

Swaps contents with another stack.

Parameters
otherThe stack to swap with.

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