31 #ifndef ETL_PACKET_INCLUDED
32 #define ETL_PACKET_INCLUDED
35 #include "static_assert.h"
56 template <
typename TBase,
size_t SIZE,
size_t ALIGNMENT>
63 #if ETL_CPP11_SUPPORTED
70 typedef typename etl::types<T>::type type;
73 ETL_STATIC_ASSERT(
sizeof(type) <= SIZE,
"Unsupported size");
76 ::new (
static_cast<type*
>(data)) type(etl::forward<T>(value));
86 ETL_STATIC_ASSERT(
sizeof(T) <= SIZE,
"Unsupported size");
89 ::new (
static_cast<T*
>(data)) T(value);
98 static_cast<TBase*
>(data)->~TBase();
101 #if ETL_CPP11_SUPPORTED
106 template <
typename T>
109 typedef typename etl::types<T>::type type;
112 ETL_STATIC_ASSERT(
sizeof(type) <= SIZE,
"Unsupported size");
115 static_cast<TBase*
>(data)->~TBase();
116 ::new (
static_cast<type*
>(data)) type(etl::forward<T>(value));
125 template <
typename T>
129 ETL_STATIC_ASSERT(
sizeof(T) <= SIZE,
"Unsupported size");
132 static_cast<TBase*
>(data)->~TBase();
133 ::new (
static_cast<T*
>(data)) T(value);
144 return *
static_cast<TBase*
>(data);
152 return *
static_cast<const TBase*
>(data);
TBase & get()
Get access to the contained object.
Definition: packet.h:142
~packet()
Destructor.
Definition: packet.h:96
packet & operator=(const T &value)
Definition: packet.h:126
packet(const T &value)
Constructor that static asserts any types that do not conform to the max size and alignment.
Definition: packet.h:83
const TBase & get() const
Get access to the contained object.
Definition: packet.h:150
add_rvalue_reference
Definition: type_traits_generator.h:1348
is_base_of
Definition: type_traits_generator.h:1289
Definition: absolute.h:37
Definition: alignment.h:118