C++ Channel
Loading...
Searching...
No Matches
Public Member Functions | List of all members
msd::vector_storage< T > Class Template Reference

A FIFO queue storage using std::vector. More...

#include <storage.hpp>

Public Member Functions

 vector_storage (std::size_t capacity)
 Constructs a queue storage with a given capacity.
 
template<typename Type >
void push_back (Type &&value)
 Adds an element to the back of the vector.
 
void pop_front (T &out)
 Removes the front element from the vector and moves it to the output.
 
NODISCARD std::size_t size () const noexcept
 Returns the number of elements currently stored.
 

Detailed Description

template<typename T>
class msd::vector_storage< T >

A FIFO queue storage using std::vector.

Template Parameters
TType of elements stored.

Constructor & Destructor Documentation

◆ vector_storage()

template<typename T >
msd::vector_storage< T >::vector_storage ( std::size_t  capacity)
inlineexplicit

Constructs a queue storage with a given capacity.

Parameters
capacityMaximum number of elements the storage can hold.
Note
Reserves the memory in advance.
Warning
Do not construct manually. This constructor may change anytime.

Member Function Documentation

◆ pop_front()

template<typename T >
void msd::vector_storage< T >::pop_front ( T out)
inline

Removes the front element from the vector and moves it to the output.

Parameters
outReference to the variable where the front element will be moved.
Warning
It's undefined behaviour to pop from an empty vector.

◆ push_back()

template<typename T >
template<typename Type >
void msd::vector_storage< T >::push_back ( Type &&  value)
inline

Adds an element to the back of the vector.

Template Parameters
TypeType of the element to insert.
Parameters
valueThe value to insert (perfect forwarded).

◆ size()

template<typename T >
NODISCARD std::size_t msd::vector_storage< T >::size ( ) const
inlinenoexcept

Returns the number of elements currently stored.

Returns
Current size.

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