Embedded Template Library 1.0
Loading...
Searching...
No Matches
etl::typed_storage< T > Class Template Reference

#include <alignment.h>

Public Types

typedef T value_type
 
typedef Treference
 
typedef const Tconst_reference
 
typedef Tpointer
 
typedef const Tconst_pointer
 

Public Member Functions

 ~typed_storage ()
 
bool has_value () const
 
template<typename T1 >
reference create (const T1 &t1)
 
template<typename T1 , typename T2 >
reference create (const T1 &t1, const T2 &t2)
 
template<typename T1 , typename T2 , typename T3 >
reference create (const T1 &t1, const T2 &t2, const T3 &t3)
 
template<typename T1 , typename T2 , typename T3 , typename T4 >
reference create (const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4)
 
void destroy ()
 Calls the destructor of the wrapped object and asserts if has_value() is false.
 
pointer operator-> ()
 
const_pointer operator-> () const
 
reference operator* ()
 
const_reference operator* () const
 

Detailed Description

template<typename T>
class etl::typed_storage< T >

Wrapper class that provides a memory area and lets the user create an instance of T in this memory at runtime. This class also erases the destructor call of T, i.e. if typed_storage goes out of scope, the destructor if the wrapped type will not be called. This can be done explicitly by calling destroy().

Template Parameters
TType of element stored in this instance of typed_storage.

Constructor & Destructor Documentation

◆ ~typed_storage()

template<typename T >
etl::typed_storage< T >::~typed_storage ( )
inline

Default destructor which will NOT call the destructor of the object which was created by calling create().

Member Function Documentation

◆ create() [1/4]

template<typename T >
template<typename T1 >
reference etl::typed_storage< T >::create ( const T1 t1)
inline

Constructs the instance of T with type T1 asserts if has_value() is false.

Returns
the instance of T which has been constructed in the internal byte array.

◆ create() [2/4]

template<typename T >
template<typename T1 , typename T2 >
reference etl::typed_storage< T >::create ( const T1 t1,
const T2 t2 
)
inline

Constructs the instance of T with types T1, T2 asserts if has_value() is false.

Returns
the instance of T which has been constructed in the internal byte array.

◆ create() [3/4]

template<typename T >
template<typename T1 , typename T2 , typename T3 >
reference etl::typed_storage< T >::create ( const T1 t1,
const T2 t2,
const T3 t3 
)
inline

Constructs the instance of T with types T1, T2, T3 asserts if has_value() is false.

Returns
the instance of T which has been constructed in the internal byte array.

◆ create() [4/4]

template<typename T >
reference etl::typed_storage< T >::create ( const T1 t1,
const T2 t2,
const T3 t3,
const T4 t4 
)
inline

Constructs the instance of T with types T1, T2, T3, T4 asserts if has_value() is false.

Returns
the instance of T which has been constructed in the internal byte array.

◆ has_value()

template<typename T >
bool etl::typed_storage< T >::has_value ( ) const
inline
Returns
true if object has been constructed using create().
false otherwise.

◆ operator*() [1/2]

template<typename T >
reference etl::typed_storage< T >::operator* ( )
inline
Returns
reference of type T and asserts if has_value() is false.

◆ operator*() [2/2]

template<typename T >
const_reference etl::typed_storage< T >::operator* ( ) const
inline
Returns
const reference of type T and asserts if has_value() is false.

◆ operator->() [1/2]

template<typename T >
pointer etl::typed_storage< T >::operator-> ( )
inline
Returns
a pointer of type T and asserts if has_value() is false.

◆ operator->() [2/2]

template<typename T >
const_pointer etl::typed_storage< T >::operator-> ( ) const
inline
Returns
a const pointer of type T and asserts if has_value() is false.

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