31#ifndef ETL_ALIGNMENT_INCLUDED
32#define ETL_ALIGNMENT_INCLUDED
36#include "static_assert.h"
101 template <
size_t Alignment>
105 return (address % Alignment) == 0
U;
111 template <
typename T>
117 namespace private_alignment
123 template <
bool Is_Match,
size_t Alignment,
typename...
TRest>
124 class type_with_alignment_matcher;
127 template <
size_t Alignment,
typename T1,
typename...
TRest>
128 class type_with_alignment_matcher<true, Alignment,
T1,
TRest...>
136 template <
size_t Alignment,
typename T1,
typename T2,
typename...
TRest>
137 class type_with_alignment_matcher <false, Alignment,
T1,
T2,
TRest...>
145 template <
size_t Alignment,
typename T1>
146 class type_with_alignment_matcher <false, Alignment,
T1>
156 template <
size_t Alignment,
typename T1,
typename...
T>
157 class type_with_alignment_helper
172 template <
size_t Alignment,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6,
typename T7,
typename T8>
181 template <
size_t Alignment,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6,
typename T7,
typename T8>
190 template <
size_t Alignment>
201 template <
size_t Alignment,
typename T1,
typename T2 =
void,
typename T3 =
void,
typename T4 =
void,
216 template <
size_t Alignment>
222 typedef struct {
alignas(Alignment)
char dummy; } type;
224 #if ETL_NOT_USING_64BIT_TYPES
235 template <
size_t Alignment>
244 template <
size_t Length, const
size_t Alignment>
250 template <
typename T>
259 template <
typename T>
260 operator const T& ()
const
268 template <
typename T>
272 return reinterpret_cast<T*
>(data);
276 template <
typename T>
277 operator const T* ()
const
280 return reinterpret_cast<const T*
>(data);
284 template <
typename T>
293 template <
typename T>
302 template <
typename T>
306 return reinterpret_cast<T*
>(data);
310 template <
typename T>
314 return reinterpret_cast<const T*
>(data);
317#if ETL_USING_CPP11 && !defined(ETL_COMPILER_ARM5)
318 alignas(Alignment)
char data[
Length];
323 typename etl::type_with_alignment<Alignment>::type etl_alignment_type;
330 template <
size_t Length, const
size_t Alignment>
338 template <
size_t Length,
typename T>
344 template <
size_t Length,
typename T>
356 template <
typename T>
361 typedef T value_type;
362 typedef T& reference;
363 typedef const T& const_reference;
365 typedef const T* const_pointer;
379 template <
typename...
TArgs>
389 template <
typename T1>
399 template <
typename T1,
typename T2>
409 template <
typename T1,
typename T2,
typename T3>
419 template <
typename T1,
typename T2,
typename T3,
typename T4>
450 template <
typename...
TArgs>
451 reference
create(
TArgs&&...
args) ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
463 template <
typename T1>
467 pointer p =
::new (&storage.value) value_type(
t1);
476 template <
typename T1,
typename T2>
480 pointer p =
::new (&storage.value) value_type(
t1,
t2);
489 template <
typename T1,
typename T2,
typename T3>
493 pointer p =
::new (&storage.value) value_type(
t1,
t2,
t3);
502 template <
typename T1,
typename T2,
typename T3,
typename T4>
506 pointer p =
::new (&storage.value) value_type(
t1,
t2,
t3,
t4);
527 pointer
operator->() ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
531 return &storage.value;
541 return &storage.value;
547 reference
operator*() ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
570 union_type() ETL_NOEXCEPT
575 ~union_type() ETL_NOEXCEPT
594 template <
typename T>
599 typedef T value_type;
600 typedef T& reference;
601 typedef const T& const_reference;
603 typedef const T* const_pointer;
605 template <
typename U>
612 : pbuffer(reinterpret_cast<T*>(pbuffer_)),
622 template <
typename... TArgs>
623 typed_storage_ext(
void* pbuffer_, TArgs&&... args) ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
624 : pbuffer(reinterpret_cast<T*>(pbuffer_))
635 typed_storage_ext(typed_storage_ext<T>&& other) ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
636 : pbuffer(other.pbuffer)
639 other.pbuffer = ETL_NULLPTR;
646 template <
typename T1>
648 : pbuffer(reinterpret_cast<T*>(pbuffer_))
658 template <
typename T1,
typename T2>
660 : pbuffer(reinterpret_cast<T*>(pbuffer_))
670 template <
typename T1,
typename T2,
typename T3>
672 : pbuffer(reinterpret_cast<T*>(pbuffer_))
682 template <
typename T1,
typename T2,
typename T3,
typename T4>
684 : pbuffer(reinterpret_cast<T*>(pbuffer_))
715 template <
typename... TArgs>
716 reference
create(TArgs&&... args) ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
728 template <
typename T1>
732 pointer p = ::new (pbuffer) value_type(t1);
741 template <
typename T1,
typename T2>
742 reference
create(
const T1& t1,
const T2& t2)
745 pointer p = ::new (pbuffer) value_type(t1, t2);
754 template <
typename T1,
typename T2,
typename T3>
755 reference
create(
const T1& t1,
const T2& t2,
const T3& t3)
758 pointer p = ::new (pbuffer) value_type(t1, t2, t3);
767 template <
typename T1,
typename T2,
typename T3,
typename T4>
768 reference
create(
const T1& t1,
const T2& t2,
const T3& t3,
const T4& t4)
771 pointer p = ::new (pbuffer) value_type(t1, t2, t3, t4);
792 pointer
operator->() ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
802 const_pointer
operator->() const ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
812 reference
operator*() ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
814 return *operator->();
820 const_reference
operator*() const ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
822 return *operator->();
837 template <
typename T>
840 using ETL_OR_STD::swap;
Memory misalignment exception.
Definition alignment.h:67
Exception base for alignment.
Definition alignment.h:54
Definition alignment.h:204
Definition alignment.h:169
Typed storage exception.
Definition alignment.h:80
Definition alignment.h:596
typed_storage_ext(void *pbuffer_) ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
Constructor.
Definition alignment.h:611
typed_storage_ext(void *pbuffer_, const T1 &t1, const T2 &t2)
Constructs the instance of T with types T1, T2.
Definition alignment.h:659
const_reference operator*() const ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
Definition alignment.h:820
reference create(const T1 &t1, const T2 &t2)
Definition alignment.h:742
pointer operator->() ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
Definition alignment.h:792
reference create(const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4)
Definition alignment.h:768
reference create(const T1 &t1, const T2 &t2, const T3 &t3)
Definition alignment.h:755
typed_storage_ext(void *pbuffer_, const T1 &t1)
Constructs the instance of T with type T1.
Definition alignment.h:647
void destroy() ETL_NOEXCEPT
Calls the destructor of the stored object, if created.
Definition alignment.h:780
~typed_storage_ext() ETL_NOEXCEPT
Definition alignment.h:696
bool has_value() const ETL_NOEXCEPT
Definition alignment.h:705
typed_storage_ext(void *pbuffer_, const T1 &t1, const T2 &t2, const T3 &t3)
Constructs the instance of T with types T1, T2, T3.
Definition alignment.h:671
reference operator*() ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
Definition alignment.h:812
typed_storage_ext(void *pbuffer_, const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4)
Constructs the instance of T with types T1, T2, T3, T4.
Definition alignment.h:683
reference create(const T1 &t1)
Definition alignment.h:729
const_pointer operator->() const ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
Definition alignment.h:802
Definition alignment.h:358
reference create(const T1 &t1, const T2 &t2)
Definition alignment.h:477
reference create(const T1 &t1)
Definition alignment.h:464
reference operator*() ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
Definition alignment.h:547
void destroy() ETL_NOEXCEPT
Calls the destructor of the stored object, if created.
Definition alignment.h:515
bool has_value() const ETL_NOEXCEPT
Definition alignment.h:440
typed_storage(const T1 &t1)
Constructs the instance of T with type T1.
Definition alignment.h:390
const_reference operator*() const ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
Definition alignment.h:555
~typed_storage() ETL_NOEXCEPT
Definition alignment.h:431
const_pointer operator->() const ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
Definition alignment.h:537
reference create(const T1 &t1, const T2 &t2, const T3 &t3)
Definition alignment.h:490
pointer operator->() ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
Definition alignment.h:527
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.
Definition alignment.h:420
typed_storage(const T1 &t1, const T2 &t2, const T3 &t3)
Constructs the instance of T with types T1, T2, T3.
Definition alignment.h:410
reference create(const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4)
Definition alignment.h:503
typed_storage(const T1 &t1, const T2 &t2)
Constructs the instance of T with types T1, T2.
Definition alignment.h:400
Definition alignment.h:218
Definition alignment.h:246
Definition alignment.h:340
#define ETL_ASSERT(b, e)
Definition error_handler.h:356
Definition exception.h:47
add_rvalue_reference
Definition type_traits_generator.h:1413
is_same
Definition type_traits_generator.h:1104
bitset_ext
Definition absolute.h:39
ETL_CONSTEXPR14 void swap(etl::typed_storage_ext< T > &lhs, etl::typed_storage_ext< T > &rhs) ETL_NOEXCEPT
Swap two etl::typed_storage_ext.
Definition alignment.h:838
T * create(Args &&... args)
Creates the object from a type. Variadic parameter constructor.
Definition variant_pool_generator.h:348
bool is_aligned(const void *p, size_t required_alignment)
Check that 'p' has 'required_alignment'.
Definition alignment.h:92
ETL_NODISCARD ETL_CONSTEXPR14 T round_half_even_unscaled(T value) ETL_NOEXCEPT
Definition scaled_rounding.h:315
Definition alignment.h:248
const T * get_address() const
Get address as const T pointer.
Definition alignment.h:311
T * get_address()
Get address as T pointer.
Definition alignment.h:303
const T & get_reference() const
Get address as const T reference.
Definition alignment.h:294
T & get_reference()
Get address as T reference.
Definition alignment.h:285