A C++ template library for embedded applications
MIT licensed
Designed and
maintained by
John Wellbelove

Alignment

A way of aligning memory storage through template parameters.
____________________________________________________________________________________________________

type_with_alignment

Returns a fundamental type that has the same alignment as that specified in the template parameter.

template <const size_t ALIGNMENT>
class type_with_alignment

Example

typedef etl::type_with_alignment<4>::type type_t;
____________________________________________________________________________________________________

aligned_storage

Creates a memory store of the specified length at the specified alignment.

template <const size_t LENGTH, const size_t ALIGNMENT>
struct aligned_storage;

Example

// Creates aligned storage of length 100 at an alignment of 8.
etl::aligned_storage<100, 8>::type storage;

The class defines various conversion operators for ease of use.

Conversions are supplied to T&, const T&, T*, const T*, plus explicit get_address and get_reference member functions.
____________________________________________________________________________________________________

aligned_storage_as

Creates a memory store of the specified length at the same alignment as the specified type.

template <const size_t LENGTH, typename T>
struct aligned_storage_as;

Example

// Creates aligned storage of length 100 at an alignment of a double.
etl::aligned_storage_as<100, double>::type storage;

____________________________________________________________________________________________________

is_aligned

20.35.12
bool is_aligned(void* p, size_t alignment)
Check that p has alignment
____________________________________________________________________________________________________
template <size_t Alignment>
bool is_aligned(void* p)
Check that p has Alignment
____________________________________________________________________________________________________
template <typename T>
bool is_aligned(void* p)
Check that p has the alignment of T
____________________________________________________________________________________________________

alignment_exception

20.35.12

Exception base for alignment
____________________________________________________________________________________________________

alignment_error

20.35.12

Memory misalignment exception.

alignment.h