All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | List of all members
blaze::AlignedArray< Type, N, Alignment > Class Template Reference

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...
 

Detailed Description

template<typename Type, size_t N, size_t Alignment = AlignmentTrait<Type>::value>
class blaze::AlignedArray< Type, N, Alignment >

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:

template< typename Type, size_t N, size_t Alignment >

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:

void func( const int* );
array[10] = 2; // Accessing and assigning the 10th array element
func( array ); // Passing the aligned array to a function expecting a pointer

Currently, the only limitation is that an aligned array cannot be statically initialized via array initialization:

blaze::AlignedArray<int,3UL> array = { 1, 2, 3 }; // Compilation error!

This limitation will be resolved when AlignedArray is updated to C++11.

Member Function Documentation

template<typename Type , size_t N, size_t Alignment>
AlignedArray< Type, N, Alignment >::Pointer blaze::AlignedArray< Type, N, Alignment >::data ( )
inline

Low-level data access to the array elements.

Returns
Pointer to the internal element storage.

This function returns a pointer to the internal storage of the aligned array.

template<typename Type , size_t N, size_t Alignment>
AlignedArray< Type, N, Alignment >::ConstPointer blaze::AlignedArray< Type, N, Alignment >::data ( ) const
inline

Low-level data access to the array elements.

Returns
Pointer to the internal element storage.

This function returns a pointer to the internal storage of the aligned array.

template<typename Type , size_t N, size_t Alignment>
blaze::AlignedArray< Type, N, Alignment >::operator ConstPointer ( ) const
inline

Conversion operator to a pointer-to-const.

Returns
The raw pointer of the aligned array.
template<typename Type , size_t N, size_t Alignment>
blaze::AlignedArray< Type, N, Alignment >::operator Pointer ( )
inline

Conversion operator to a pointer.

Returns
The raw pointer of the aligned array.
template<typename Type , size_t N, size_t Alignment>
AlignedArray< Type, N, Alignment >::Reference blaze::AlignedArray< Type, N, Alignment >::operator[] ( size_t  index)
inline

Subscript operator for the direct access to the array elements.

Parameters
indexAccess index. The index has to be in the range $[0..N-1]$.
Returns
Reference to the accessed value.

In case BLAZE_USER_ASSERT() is active, this operator performs an index check.

template<typename Type , size_t N, size_t Alignment>
AlignedArray< Type, N, Alignment >::ConstReference blaze::AlignedArray< Type, N, Alignment >::operator[] ( size_t  index) const
inline

Subscript operator for the direct access to the array elements.

Parameters
indexAccess index. The index has to be in the range $[0..N-1]$.
Returns
Reference-to-const to the accessed value.

In case BLAZE_USER_ASSERT() is active, this operator performs an index check.


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