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 T & reference
typedef const T & const_reference
typedef T * pointer
typedef const T * const_pointer

Public Member Functions

template<typename T1>
 typed_storage (const T1 &t1)
 Constructs the instance of T with type T1.
template<typename T1, typename T2>
 typed_storage (const T1 &t1, const T2 &t2)
 Constructs the instance of T with types T1, T2.
template<typename T1, typename T2, typename T3>
 typed_storage (const T1 &t1, const T2 &t2, const T3 &t3)
 Constructs the instance of T with types T1, T2, T3.
template<typename T1, typename T2, typename T3, typename T4>
 typed_storage (const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4)
 Constructs the instance of T with types T1, T2, T3, T4.
 ~typed_storage () ETL_NOEXCEPT
bool has_value () const ETL_NOEXCEPT
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 () ETL_NOEXCEPT
 Calls the destructor of the stored object, if created.
pointer operator-> () ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
const_pointer operator-> () const ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
reference operator* () ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
const_reference operator* () const ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)

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

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

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

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

◆ create() [4/4]

template<typename T>
template<typename T1, typename T2, typename T3, typename T4>
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

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>
const_reference etl::typed_storage< T >::operator* ( ) const
inline
Returns
const_reference of type T and asserts if has_value() is false.

◆ operator*() [2/2]

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

◆ operator->() [1/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.

◆ operator->() [2/2]

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

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