A small array with a compile-time constant number of elements. More...
Public Types | |
typedef std::size_t | size_type |
A type suitable to store the number of elements in an array. | |
typedef std::ptrdiff_t | difference_type |
A type suitable for addition or subtraction from an array index or iterator. | |
typedef T | value_type |
The type of the values contained in this array. | |
typedef T & | reference |
A reference to array::value_type. | |
typedef const T & | const_reference |
A reference to a const array::value_type. | |
typedef T * | pointer |
A pointer to array::value_type. | |
typedef const T * | const_pointer |
A pointer to const array::value_type. | |
typedef T * | iterator |
An iterator into an std::array. | |
typedef const T * | const_iterator |
A constant iterator into an std::array. | |
typedef std::reverse_iterator < iterator > | reverse_iterator |
A reverse iterator into an std::array. | |
typedef std::reverse_iterator < const_iterator > | const_reverse_iterator |
A constant reverse iterator into an std::array. | |
Public Member Functions | |
void | fill (const T &t) |
Assigns t to every element of the array. | |
void | assign (const T &t) |
Assigns t to every element of the array. | |
void | swap (array &other) |
Calls swap() pairwise on each member of this and the other array. | |
iterator | begin () |
Returns an iterator to the first element of this array. | |
const_iterator | begin () const |
Returns a const iterator to the first element of this array. | |
iterator | end () |
Returns an iterator to the end of this array. | |
const_iterator | end () const |
Returns a const iterator to the end of this array. | |
reverse_iterator | rbegin () |
Returns a reverse iterator to the last element of this array. | |
const_reverse_iterator | rbegin () const |
Returns a const reverse iterator to the last element of this array. | |
reverse_iterator | rend () |
Returns a reverse iterator to the end of a reverse traversal of this array. | |
const_reverse_iterator | rend () const |
Returns a const reverse iterator to the end of a reverse traversal of this array. | |
const_iterator | cbegin () const |
Equivalent to array::begin() const, even if *this is not const. | |
const_iterator | cend () const |
Equivalent to array::end() const, even if *this is not const. | |
const_reverse_iterator | crbegin () const |
Equivalent to array::rbegin() const, even if *this is not const. | |
const_reverse_iterator | crend () const |
Equivalent to array::rend() const, even if *this is not const. | |
size_type | size () const |
Returns the number of elements contained in this array. | |
size_type | max_size () const |
Returns the size of the largest array<N, T>. | |
bool | empty () const |
Returns true if and only if this->size() == 0. | |
reference | operator[] (size_type i) |
Returns a reference to the element at the provided position. | |
const_reference | operator[] (size_type i) const |
Returns a const reference to the element at the provided position. | |
reference | at (size_type i) |
Returns a reference to the element at the provided position. | |
const_reference | at (size_type i) const |
Returns a const reference to the element at the provided position. | |
reference | front () |
Returns a reference to the first element in this array. | |
const_reference | front () const |
Returns a const reference to the first element in this array. | |
reference | back () |
Returns a reference to the last element in this array. | |
const_reference | back () const |
Returns a const reference to the last element in this array. | |
T * | data () |
Returns a pointer to the data contained in this array. | |
const T * | data () const |
Returns a const pointer to the data contained in this array. | |
template<typename S > | |
array< S, N > | as () const |
Casts each element of this array to the destination type and returns an array containing all the casted values in order. | |
template<typename U > | |
const array & | operator>>= (const array< U, N > &a) |
Applies operator>>=() to every element of the array and returns a reference to *this. | |
template<typename U > | |
const array & | operator<<= (const array< U, N > &a) |
Applies operator<<=() to every element of the array and returns a reference to *this. |
A small array with a compile-time constant number of elements.
Instances of this class should be initialized as aggregates, for example:
arbb::array<double, 4> a = {0.0, 1.0, -1.0, 5.0};
You cannot perform implicit type conversions of arrays inside expressions. For example, the following code is incorrect:
arbb::array<double, 2> a = {0.0, 1.0}; arbb::array<float, 2> b = {-1.0, 5.0}; arbb::array<double, 2> c = a + b; // NOT LEGAL
Instead, use the array::as() member function to cast explicitly:
arbb::array<double, 2> a = {0.0, 1.0}; arbb::array<float, 2> b = {-1.0, 5.0}; arbb::array<double, 2> c = a + b.as<float>(); // OK!
Arrays of built-in Intel(R) ArBB types or user-defined ArBB (element) types are themselves user-defined ArBB (element) types. This means that you can pass array instances to ArBB closures, and construct containers with arrays as their element type, as long as the array is composed of ArBB types.
This class mimics the tr1::array class from the C++ Technical Report on C++ Library extensions, but adds many extensions, including the same element-wise and collective operations that are supported by containers such as arbb::dense.
T | Element type of the array. | |
N | Number of elements in the array. |
Definition at line 75 of file array.hpp.
typedef std::size_t arbb::array< T, N >::size_type |
typedef std::ptrdiff_t arbb::array< T, N >::difference_type |
typedef T arbb::array< T, N >::value_type |
typedef T& arbb::array< T, N >::reference |
typedef const T& arbb::array< T, N >::const_reference |
A reference to a const array::value_type.
typedef T* arbb::array< T, N >::pointer |
typedef const T* arbb::array< T, N >::const_pointer |
typedef T* arbb::array< T, N >::iterator |
typedef const T* arbb::array< T, N >::const_iterator |
typedef std::reverse_iterator<iterator> arbb::array< T, N >::reverse_iterator |
typedef std::reverse_iterator<const_iterator> arbb::array< T, N >::const_reverse_iterator |
A constant reverse iterator into an std::array.
void arbb::array< T, N >::fill | ( | const T & | t | ) |
Assigns t to every element of the array.
void arbb::array< T, N >::assign | ( | const T & | t | ) |
Assigns t to every element of the array.
void arbb::array< T, N >::swap | ( | array< T, N > & | other | ) |
Calls swap() pairwise on each member of this and the other array.
This function performs N swap operations and does not execute in constant time.
iterator arbb::array< T, N >::begin | ( | ) |
Returns an iterator to the first element of this array.
If the array is empty, returns array::end().
const_iterator arbb::array< T, N >::begin | ( | ) | const |
Returns a const iterator to the first element of this array.
If the array is empty, returns array::end().
iterator arbb::array< T, N >::end | ( | ) |
Returns an iterator to the end of this array.
const_iterator arbb::array< T, N >::end | ( | ) | const |
Returns a const iterator to the end of this array.
reverse_iterator arbb::array< T, N >::rbegin | ( | ) |
Returns a reverse iterator to the last element of this array.
If the array is empty, returns array::rend().
const_reverse_iterator arbb::array< T, N >::rbegin | ( | ) | const |
Returns a const reverse iterator to the last element of this array.
If the array is empty, returns array::rend().
reverse_iterator arbb::array< T, N >::rend | ( | ) |
Returns a reverse iterator to the end of a reverse traversal of this array.
const_reverse_iterator arbb::array< T, N >::rend | ( | ) | const |
Returns a const reverse iterator to the end of a reverse traversal of this array.
const_iterator arbb::array< T, N >::cbegin | ( | ) | const |
Equivalent to array::begin() const, even if *this is not const.
const_iterator arbb::array< T, N >::cend | ( | ) | const |
Equivalent to array::end() const, even if *this is not const.
const_reverse_iterator arbb::array< T, N >::crbegin | ( | ) | const |
Equivalent to array::rbegin() const, even if *this is not const.
const_reverse_iterator arbb::array< T, N >::crend | ( | ) | const |
Equivalent to array::rend() const, even if *this is not const.
size_type arbb::array< T, N >::size | ( | ) | const |
Returns the number of elements contained in this array.
Always returns N.
size_type arbb::array< T, N >::max_size | ( | ) | const |
Returns the size of the largest array<N, T>.
As with calling this->size(), this function simply returns N.
bool arbb::array< T, N >::empty | ( | ) | const |
Returns true if and only if this->size() == 0.
reference arbb::array< T, N >::operator[] | ( | size_type | i | ) |
Returns a reference to the element at the provided position.
Attempting to access an element at an index larger than or equal to the array size yields undefined behavior.
const_reference arbb::array< T, N >::operator[] | ( | size_type | i | ) | const |
Returns a const reference to the element at the provided position.
Attempting to access an element at an index larger than or equal to the array size yields undefined behavior.
reference arbb::array< T, N >::at | ( | size_type | i | ) |
Returns a reference to the element at the provided position.
Attempting to access an element at an index larger than or equal to the array size throws an std::out_of_range exception.
const_reference arbb::array< T, N >::at | ( | size_type | i | ) | const |
Returns a const reference to the element at the provided position.
Attempting to access an element at an index larger than or equal to the array size throws an std::out_of_range exception.
reference arbb::array< T, N >::front | ( | ) |
Returns a reference to the first element in this array.
Attempting to call this function on an empty array yields undefined behavior.
const_reference arbb::array< T, N >::front | ( | ) | const |
Returns a const reference to the first element in this array.
Attempting to call this function on an empty array yields undefined behavior.
reference arbb::array< T, N >::back | ( | ) |
Returns a reference to the last element in this array.
Attempting to call this function on an empty array yields undefined behavior.
const_reference arbb::array< T, N >::back | ( | ) | const |
Returns a const reference to the last element in this array.
Attempting to call this function on an empty array yields undefined behavior.
T* arbb::array< T, N >::data | ( | ) |
Returns a pointer to the data contained in this array.
If the array is empty, the return value is unspecified.
const T* arbb::array< T, N >::data | ( | ) | const |
Returns a const pointer to the data contained in this array.
If the array is empty, the return value is unspecified.
array<S, N> arbb::array< T, N >::as | ( | ) | const [inline] |
Casts each element of this array to the destination type and returns an array containing all the casted values in order.
This function uses static_cast<> to cast the elements.
const array& arbb::array< T, N >::operator>>= | ( | const array< U, N > & | a | ) | [inline] |
Applies operator>>=() to every element of the array and returns a reference to *this.
const array& arbb::array< T, N >::operator<<= | ( | const array< U, N > & | a | ) | [inline] |
Applies operator<<=() to every element of the array and returns a reference to *this.
Copyright © 2010, Intel Corporation. All rights reserved.