Templatious
 All Classes Functions Pages
Public Member Functions | Static Public Attributes | List of all members
templatious::StaticBuffer< T, sz > Struct Template Reference

#include <StaticVector.hpp>

Public Member Functions

auto getStaticVector (int capacity) -> StaticVector< T >
 
auto getStaticVectorPre (int size) -> StaticVector< T >
 
auto getStaticVector () -> StaticVector< T >
 
auto getStaticVectorPre () -> StaticVector< T >
 

Static Public Attributes

static const int total_size = sz
 

Detailed Description

template<class T, long sz>
struct templatious::StaticBuffer< T, sz >

Class that generates static vectors whose memory resides on the stack. Vectors generated by this class use aligned memory (std::aligned_storage)

Example:

// buffer for 16 ints.
auto v1 = buffer.getStaticVector(8);
auto v2 = buffer.getStaticVector();
// v1 and v2 can each hold 8 integers.
SA::add(v1,0,1,2,3,4,5,6,7);
SA::add(v2,v1);
// adding more to v1 will throw
// SA::add(v1,8);
// No need to care about releasing
// memory or heap allocation -
// objects are destroyed automatically
Parameters
[in]TType of elements to allocate memory for.
[in]szAmount of T elements this buffer can contain.

Member Function Documentation

template<class T, long sz>
auto templatious::StaticBuffer< T, sz >::getStaticVector ( int  capacity) -> StaticVector<T>
inline

Generate static vector with a given capacity. If this exceeds the remaining memory in this buffer exception is thrown.

Parameters
[in]capacityCapacity of static vector.
template<class T, long sz>
auto templatious::StaticBuffer< T, sz >::getStaticVector ( ) -> StaticVector<T>
inline

Generate static vector with a remaining memory.

template<class T, long sz>
auto templatious::StaticBuffer< T, sz >::getStaticVectorPre ( int  size) -> StaticVector<T>
inline

Generate static vector with specified size with already preinitialized elements. Uses default constructor to initialize elements. If this exceeds the remaining memory in this buffer exception is thrown.

Parameters
[in]capacityCapacity of static vector.
template<class T, long sz>
auto templatious::StaticBuffer< T, sz >::getStaticVectorPre ( ) -> StaticVector<T>
inline

Generate static vector with a remaining memory with preinitialized elements. Uses default constructor to construct elements.


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