stator
A math, geometry, and utility library
Public Member Functions | List of all members
stator::orphan::StackVector< T, Nmax > Class Template Reference

Stack-allocated equivalent of std::vector. More...

#include <stack_vector.hpp>

Inheritance diagram for stator::orphan::StackVector< T, Nmax >:

Public Member Functions

template<size_t Nmax2>
 StackVector (const StackVector< T, Nmax2 > &vec)
 Copy constructor which allows construction from smaller StackVector types. More...
 
 StackVector ()
 Default constructor. More...
 
 StackVector (std::initializer_list< T > _list)
 Array initialisation constructor. More...
 
Base::reference back ()
 Returns a reference to the last element stored in the container. More...
 
Base::const_reference back () const
 Returns a reference to the last element stored in the container. More...
 
Base::const_iterator cend () const
 Returns a const iterator pointing to the end of the container. More...
 
Base::const_reverse_iterator crbegin () const
 Returns a const reverse iterator pointing to the start of the container. More...
 
Base::const_reverse_iterator crend () const
 Returns a const reverse iterator pointing to the end of the container. More...
 
constexpr bool empty () const
 Test if the container is empty. More...
 
Base::iterator end ()
 Returns an iterator pointing to the end of the container. More...
 
Base::const_iterator end () const
 Returns an iterator pointing to the end of the container. More...
 
template<size_t Nmax2>
void extend (const StackVector< T, Nmax2 > &ovec)
 Merge the contents of another StackVector into this one. More...
 
pop_back ()
 Removes and returns the last element of the container. More...
 
void push_back (const T &val)
 Add an element to the end of the container. More...
 
Base::reverse_iterator rbegin ()
 Returns a reverse iterator pointing to the start of the container. More...
 
Base::const_reverse_iterator rbegin () const
 Returns a reverse iterator pointing to the start of the container. More...
 
Base::reverse_iterator rend ()
 Returns a reverse iterator pointing to the end of the container. More...
 
Base::const_reverse_iterator rend () const
 Returns a reverse iterator pointing to the end of the container. More...
 
constexpr Base::size_type size () const
 The number of elements currently stored. More...
 

Detailed Description

template<class T, size_t Nmax>
class stator::orphan::StackVector< T, Nmax >

This class impersonates a STL vector, but its storage is allocated on the stack. this allows the simplicity of a vector without the overhead of dynamic memory allocation. It is usually used to return small arrays of values (e.g., a list of roots) where a maximum number of elements can be calculated at compile time.

Template Parameters
TThe stored data type.
NmaxThe maximum number of elements to be stored in the container.

Definition at line 44 of file stack_vector.hpp.

Constructor & Destructor Documentation

◆ StackVector() [1/3]

template<class T, size_t Nmax>
template<size_t Nmax2>
stator::orphan::StackVector< T, Nmax >::StackVector ( const StackVector< T, Nmax2 > &  vec)
inline

Definition at line 52 of file stack_vector.hpp.

◆ StackVector() [2/3]

template<class T, size_t Nmax>
stator::orphan::StackVector< T, Nmax >::StackVector ( )
inline

Definition at line 57 of file stack_vector.hpp.

◆ StackVector() [3/3]

template<class T, size_t Nmax>
stator::orphan::StackVector< T, Nmax >::StackVector ( std::initializer_list< T >  _list)
inline

Definition at line 60 of file stack_vector.hpp.

Member Function Documentation

◆ back() [1/2]

template<class T, size_t Nmax>
Base::reference stator::orphan::StackVector< T, Nmax >::back ( )
inline

Definition at line 109 of file stack_vector.hpp.

◆ back() [2/2]

template<class T, size_t Nmax>
Base::const_reference stator::orphan::StackVector< T, Nmax >::back ( ) const
inline

Definition at line 112 of file stack_vector.hpp.

◆ cend()

template<class T, size_t Nmax>
Base::const_iterator stator::orphan::StackVector< T, Nmax >::cend ( ) const
inline

Definition at line 82 of file stack_vector.hpp.

◆ crbegin()

template<class T, size_t Nmax>
Base::const_reverse_iterator stator::orphan::StackVector< T, Nmax >::crbegin ( ) const
inline

Definition at line 94 of file stack_vector.hpp.

◆ crend()

template<class T, size_t Nmax>
Base::const_reverse_iterator stator::orphan::StackVector< T, Nmax >::crend ( ) const
inline

Definition at line 106 of file stack_vector.hpp.

◆ empty()

template<class T, size_t Nmax>
constexpr bool stator::orphan::StackVector< T, Nmax >::empty ( ) const
inline

Definition at line 73 of file stack_vector.hpp.

◆ end() [1/2]

template<class T, size_t Nmax>
Base::iterator stator::orphan::StackVector< T, Nmax >::end ( )
inline

Definition at line 76 of file stack_vector.hpp.

◆ end() [2/2]

template<class T, size_t Nmax>
Base::const_iterator stator::orphan::StackVector< T, Nmax >::end ( ) const
inline

Definition at line 79 of file stack_vector.hpp.

◆ extend()

template<class T, size_t Nmax>
template<size_t Nmax2>
void stator::orphan::StackVector< T, Nmax >::extend ( const StackVector< T, Nmax2 > &  ovec)
inline

Definition at line 135 of file stack_vector.hpp.

◆ pop_back()

template<class T, size_t Nmax>
T stator::orphan::StackVector< T, Nmax >::pop_back ( )
inline

Definition at line 125 of file stack_vector.hpp.

◆ push_back()

template<class T, size_t Nmax>
void stator::orphan::StackVector< T, Nmax >::push_back ( const T &  val)
inline

Definition at line 115 of file stack_vector.hpp.

◆ rbegin() [1/2]

template<class T, size_t Nmax>
Base::reverse_iterator stator::orphan::StackVector< T, Nmax >::rbegin ( )
inline

Definition at line 86 of file stack_vector.hpp.

◆ rbegin() [2/2]

template<class T, size_t Nmax>
Base::const_reverse_iterator stator::orphan::StackVector< T, Nmax >::rbegin ( ) const
inline

Definition at line 90 of file stack_vector.hpp.

◆ rend() [1/2]

template<class T, size_t Nmax>
Base::reverse_iterator stator::orphan::StackVector< T, Nmax >::rend ( )
inline

Definition at line 98 of file stack_vector.hpp.

◆ rend() [2/2]

template<class T, size_t Nmax>
Base::const_reverse_iterator stator::orphan::StackVector< T, Nmax >::rend ( ) const
inline

Definition at line 102 of file stack_vector.hpp.

◆ size()

template<class T, size_t Nmax>
constexpr Base::size_type stator::orphan::StackVector< T, Nmax >::size ( ) const
inline

Definition at line 70 of file stack_vector.hpp.


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