fesa-core  7.0.0
fesa::Aligned< T > Class Template Reference

#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
 

Detailed Description

template<class T>
class fesa::Aligned< T >

This class contains helper constants and methods for memory alignment purposes.

Member Function Documentation

template<typename T >
T * fesa::Aligned< T >::align ( const void *  memory)
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.

Parameters
memorya memory address from which alignment will be done
Returns
a memory address aligned on T's alignment constraints
template<typename T >
void fesa::Aligned< T >::mapObjectArray ( char *&  memory,
std::size_t  nObjects,
T *&  objectsPointer 
)
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.

template<typename T >
void fesa::Aligned< T >::mapObjectPointer ( char *&  memory,
T *&  objectPointer 
)
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.

template<typename T >
std::size_t fesa::Aligned< T >::unalignedArraySize ( std::size_t  nObjects)
static

Returns the size needed to map an array of nObjects objects on unaligned memory.

Member Data Documentation

template<class T >
const std::size_t fesa::Aligned< T >::unalignedSize = sizeof(T) + __alignof__(T) - 1
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.


The documentation for this class was generated from the following file: