fesa-core
7.0.0
|
#include <Aligned.h>
Static Public Member Functions | |
static std::size_t | unalignedArraySize (std::size_t nObjects) |
static T * | align (const void *memory) |
static void | mapObjectPointer (char *&memory, T *&objectPointer) |
static void | mapObjectArray (char *&memory, std::size_t nObjects, T *&objectsPointer) |
Static Public Attributes | |
static const std::size_t | unalignedSize = sizeof(T) + __alignof__(T) - 1 |
This class contains helper constants and methods for memory alignment purposes.
|
static |
From a memory address, returns another memory address which is suitable to contain an aligned T. 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 |
Maps objectsPointer to the first suitable location located at or after memory capable of containing nObjects objects. Updates memory to point to byte following the last byte used by the array.
|
static |
Maps objectPointer to the first suitable location located at or after memory. Assumes memory points to a buffer of at least unalignedSize bytes. When this returns, memory points to the byte following the last byte used by the object.
|
static |
Returns the size needed to map an array of nObjects objects on unaligned memory.
|
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.