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

using ElementType = Type
 Type of the array elements.
 
using Pointer = Type *
 Pointer to a non-constant array element.
 
using ConstPointer = const Type *
 Pointer to a constant array element.
 
using Reference = Type &
 Reference to a non-constant array element.
 
using ConstReference = const Type &
 Reference to a constant array element.
 
using Iterator = Type *
 Iterator over non-constant elements.
 
using ConstIterator = const Type *
 Iterator over constant elements.
 

Public Member Functions

Constructors
 AlignedArray ()
 The default constructor for AlignedArray.
 
template<typename... Ts>
constexpr AlignedArray (const Ts &... args)
 Initialization constructor for AlignedArray. More...
 
Conversion operators
 operator Pointer () noexcept
 Conversion operator to a pointer. More...
 
constexpr operator ConstPointer () const noexcept
 Conversion operator to a pointer-to-const. More...
 
Data access functions
Reference operator[] (size_t index) noexcept
 Subscript operator for the direct access to the array elements. More...
 
constexpr ConstReference operator[] (size_t index) const noexcept
 Subscript operator for the direct access to the array elements. More...
 
Reference at (size_t index)
 Checked access to the array elements. More...
 
ConstReference at (size_t index) const
 Checked access to the array elements. More...
 
Pointer data () noexcept
 Low-level data access to the array elements. More...
 
constexpr ConstPointer data () const noexcept
 Low-level data access to the array elements. More...
 
Iterator begin () noexcept
 Returns an iterator to the first element of the aligned array. More...
 
constexpr ConstIterator begin () const noexcept
 Returns an iterator to the first element of the aligned array. More...
 
constexpr ConstIterator cbegin () const noexcept
 Returns an iterator to the first element of the aligned array. More...
 
Iterator end () noexcept
 Returns an iterator just past the last element of the aligned array. More...
 
constexpr ConstIterator end () const noexcept
 Returns an iterator just past the last element of the aligned array. More...
 
constexpr ConstIterator cend () const noexcept
 Returns an iterator just past the last element of the aligned array. More...
 
Utility functions
constexpr size_t size () const noexcept
 Returns the current size/dimension of the aligned array. More...
 

Detailed Description

template<typename Type, size_t N, size_t Alignment = AlignmentOf<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
blaze::AlignedArray<int,3UL> array2{ 1, 2, 3 }; // Directly initialized array
blaze::AlignedArray<int,3UL> array3( 1, 2, 3 ); // Same effect as above

Constructor & Destructor Documentation

◆ AlignedArray()

template<typename Type , size_t N, size_t Alignment>
template<typename... Ts>
constexpr blaze::AlignedArray< Type, N, Alignment >::AlignedArray ( const Ts &...  args)
inlineexplicit

Initialization constructor for AlignedArray.

Parameters
argsPack of initialization values.

Member Function Documentation

◆ at() [1/2]

template<typename Type , size_t N, size_t Alignment>
AlignedArray< Type, N, Alignment >::Reference blaze::AlignedArray< Type, N, Alignment >::at ( size_t  index)
inline

Checked 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.
Exceptions
std::out_of_rangeInvalid array access index.

In contrast to the subscript operator this function always performs a check of the given access index.

◆ at() [2/2]

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

Checked 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.
Exceptions
std::out_of_rangeInvalid array access index.

In contrast to the subscript operator this function always performs a check of the given access index.

◆ begin() [1/2]

template<typename Type , size_t N, size_t Alignment>
AlignedArray< Type, N, Alignment >::Iterator blaze::AlignedArray< Type, N, Alignment >::begin ( )
inlinenoexcept

Returns an iterator to the first element of the aligned array.

Returns
Iterator to the first element of the aligned array.

◆ begin() [2/2]

template<typename Type , size_t N, size_t Alignment>
constexpr AlignedArray< Type, N, Alignment >::ConstIterator blaze::AlignedArray< Type, N, Alignment >::begin ( ) const
inlinenoexcept

Returns an iterator to the first element of the aligned array.

Returns
Iterator to the first element of the aligned array.

◆ cbegin()

template<typename Type , size_t N, size_t Alignment>
constexpr AlignedArray< Type, N, Alignment >::ConstIterator blaze::AlignedArray< Type, N, Alignment >::cbegin ( ) const
inlinenoexcept

Returns an iterator to the first element of the aligned array.

Returns
Iterator to the first element of the aligned array.

◆ cend()

template<typename Type , size_t N, size_t Alignment>
constexpr AlignedArray< Type, N, Alignment >::ConstIterator blaze::AlignedArray< Type, N, Alignment >::cend ( ) const
inlinenoexcept

Returns an iterator just past the last element of the aligned array.

Returns
Iterator just past the last element of the aligned array.

◆ data() [1/2]

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

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.

◆ data() [2/2]

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

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.

◆ end() [1/2]

template<typename Type , size_t N, size_t Alignment>
AlignedArray< Type, N, Alignment >::Iterator blaze::AlignedArray< Type, N, Alignment >::end ( )
inlinenoexcept

Returns an iterator just past the last element of the aligned array.

Returns
Iterator just past the last element of the aligned array.

◆ end() [2/2]

template<typename Type , size_t N, size_t Alignment>
constexpr AlignedArray< Type, N, Alignment >::ConstIterator blaze::AlignedArray< Type, N, Alignment >::end ( ) const
inlinenoexcept

Returns an iterator just past the last element of the aligned array.

Returns
Iterator just past the last element of the aligned array.

◆ operator ConstPointer()

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

Conversion operator to a pointer-to-const.

Returns
The raw pointer of the aligned array.

◆ operator Pointer()

template<typename Type , size_t N, size_t Alignment>
blaze::AlignedArray< Type, N, Alignment >::operator Pointer ( )
inlinenoexcept

Conversion operator to a pointer.

Returns
The raw pointer of the aligned array.

◆ operator[]() [1/2]

template<typename Type , size_t N, size_t Alignment>
AlignedArray< Type, N, Alignment >::Reference blaze::AlignedArray< Type, N, Alignment >::operator[] ( size_t  index)
inlinenoexcept

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.
Note
This operator does not perform any kind of index check!

◆ operator[]() [2/2]

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

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.
Note
This operator does not perform any kind of index check!

◆ size()

template<typename Type , size_t N, size_t Alignment>
constexpr size_t blaze::AlignedArray< Type, N, Alignment >::size ( ) const
inlinenoexcept

Returns the current size/dimension of the aligned array.

Returns
The size of the array.

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