fesa-core
4.3.1
|
#include <Aligned.h>
Static Public Member Functions | |
static T * | align (const void *memory) |
Static Public Attributes | |
static const std::size_t | naturalAlignment = ((sizeof(T) & (sizeof(T) - 1)) == 0) ? sizeof(T) : naturalAlignmentTemp4 + 1 |
static const std::size_t | unalignedSize = naturalAlignment * 2 - 1 |
This class contains helper constants and methods for memory alignment purposes.
|
static |
From a memory address, returns another memory address which is aligned on a T's natural alignment. The returned address is greater or equal to the given address, and as close as possible to it. The result is suitable for placement new or reinterpret_cast as long as the buffer is at least unalignedSize bytes long.
memory | a memory address from which alignment will be done |
|
static |
Contains the natural alignment, in bytes, of a T. For powers of 2, this is sizeof(T). For non-powers of 2, this is the next power of 2. Examples: sizeof(T) == 8 => naturalAlignment == 8. sizeof(T) == 5 => naturalAlignment == 8. sizeof(T) == 24 => naturalAlignment == 32. sizeof(T) == 32 => naturalAlignment == 32. sizeof(T) == 33 => naturalAlignment == 64.
|
static |
Contains the maximum size (in bytes) that must be available to ensure natural alignment of a T. This can be used to allocate a buffer large enough to map an aligned T, even when alignment cannot be controlled.