![]() |
Implementation of a static array with a fixed alignment.The AlignedArray class template represents a static array with a guaranteed, fixed alignment. The type of the array elements, the number of elements and the alignment of the array can be specified via the three template parameters: More...
#include <AlignedArray.h>
Public Types | |
typedef Type * | Pointer |
Pointer to a non-constant array element. | |
typedef const Type * | ConstPointer |
Pointer to a constant array element. | |
typedef Type & | Reference |
Reference to a non-constant array element. | |
typedef const Type & | ConstReference |
Reference to a constant array element. | |
Public Member Functions | |
Constructors | |
AlignedArray () | |
The default constructor for AlignedArray. | |
Conversion operators | |
operator Pointer () | |
Conversion operator to a pointer. More... | |
operator ConstPointer () const | |
Conversion operator to a pointer-to-const. More... | |
Data access functions | |
Reference | operator[] (size_t index) |
Subscript operator for the direct access to the array elements. More... | |
ConstReference | operator[] (size_t index) const |
Subscript operator for the direct access to the array elements. More... | |
Pointer | data () |
Low-level data access to the array elements. More... | |
ConstPointer | data () const |
Low-level data access to the array elements. More... | |
Implementation of a static array with a fixed alignment.
The AlignedArray class template represents a static array with a guaranteed, fixed alignment. The type of the array elements, the number of elements and the alignment of the array can be specified via the three template parameters:
The alignment of the array, which must be a power of two (i.e. 1, 2, 4, 8, ...), can either be specified explicitly via the template parameter Alignment or it is evaluated automatically based on the alignment requirements of the given data type Type. In the latter case, if T is a built-in, vectorizable data type, AlignedArray enforces an alignment of 16 or 32 bytes, depending on the active SSE/AVX level. In all other cases, no specific alignment is enforced.
AlignedArray can be used exactly like any built-in static array. It is possible to access the individual element via the subscript operator and the array can be used wherever a pointer is expected:
Currently, the only limitation is that an aligned array cannot be statically initialized via array initialization:
This limitation will be resolved when AlignedArray is updated to C++11.
|
inline |
Low-level data access to the array elements.
This function returns a pointer to the internal storage of the aligned array.
|
inline |
Low-level data access to the array elements.
This function returns a pointer to the internal storage of the aligned array.
|
inline |
Conversion operator to a pointer-to-const.
|
inline |
Conversion operator to a pointer.
|
inline |
Subscript operator for the direct access to the array elements.
index | Access index. The index has to be in the range ![]() |
In case BLAZE_USER_ASSERT() is active, this operator performs an index check.
|
inline |
Subscript operator for the direct access to the array elements.
index | Access index. The index has to be in the range ![]() |
In case BLAZE_USER_ASSERT() is active, this operator performs an index check.