arbb::array< T, N > Struct Template Reference

A small array with a compile-time constant number of elements. More...

List of all members.

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 arrayoperator>>= (const array< U, N > &a)
 Applies operator>>=() to every element of the array and returns a reference to *this.
template<typename U >
const arrayoperator<<= (const array< U, N > &a)
 Applies operator<<=() to every element of the array and returns a reference to *this.

Detailed Description

template<typename T, std::size_t N>
struct arbb::array< T, N >

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.

Template Parameters:

T Element type of the array.
N Number of elements in the array.

Definition at line 75 of file array.hpp.


Member Typedef Documentation

template<typename T, std::size_t N>
typedef std::size_t arbb::array< T, N >::size_type

A type suitable to store the number of elements in an array.

Definition at line 77 of file array.hpp.

template<typename T, std::size_t N>
typedef std::ptrdiff_t arbb::array< T, N >::difference_type

A type suitable for addition or subtraction from an array index or iterator.

Definition at line 79 of file array.hpp.

template<typename T, std::size_t N>
typedef T arbb::array< T, N >::value_type

The type of the values contained in this array.

Definition at line 82 of file array.hpp.

template<typename T, std::size_t N>
typedef T& arbb::array< T, N >::reference

A reference to array::value_type.

See Also

value_type

Definition at line 85 of file array.hpp.

template<typename T, std::size_t N>
typedef const T& arbb::array< T, N >::const_reference

A reference to a const array::value_type.

See Also

value_type

Definition at line 88 of file array.hpp.

template<typename T, std::size_t N>
typedef T* arbb::array< T, N >::pointer

A pointer to array::value_type.

See Also

value_type

Definition at line 91 of file array.hpp.

template<typename T, std::size_t N>
typedef const T* arbb::array< T, N >::const_pointer

A pointer to const array::value_type.

See Also

value_type

Definition at line 94 of file array.hpp.

template<typename T, std::size_t N>
typedef T* arbb::array< T, N >::iterator

An iterator into an std::array.

Definition at line 97 of file array.hpp.

template<typename T, std::size_t N>
typedef const T* arbb::array< T, N >::const_iterator

A constant iterator into an std::array.

Definition at line 99 of file array.hpp.

template<typename T, std::size_t N>
typedef std::reverse_iterator<iterator> arbb::array< T, N >::reverse_iterator

A reverse iterator into an std::array.

See Also

iterator

Definition at line 103 of file array.hpp.

template<typename T, std::size_t N>
typedef std::reverse_iterator<const_iterator> arbb::array< T, N >::const_reverse_iterator

A constant reverse iterator into an std::array.

See Also

const_iterator

Definition at line 106 of file array.hpp.


Member Function Documentation

template<typename T, std::size_t N>
void arbb::array< T, N >::fill ( const T &  t  ) 

Assigns t to every element of the array.

template<typename T, std::size_t N>
void arbb::array< T, N >::assign ( const T &  t  ) 

Assigns t to every element of the array.

template<typename T, std::size_t N>
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.

template<typename T, std::size_t N>
iterator arbb::array< T, N >::begin (  ) 

Returns an iterator to the first element of this array.

If the array is empty, returns array::end().

template<typename T, std::size_t N>
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().

template<typename T, std::size_t N>
iterator arbb::array< T, N >::end (  ) 

Returns an iterator to the end of this array.

template<typename T, std::size_t N>
const_iterator arbb::array< T, N >::end (  )  const

Returns a const iterator to the end of this array.

template<typename T, std::size_t N>
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().

template<typename T, std::size_t N>
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().

template<typename T, std::size_t N>
reverse_iterator arbb::array< T, N >::rend (  ) 

Returns a reverse iterator to the end of a reverse traversal of this array.

template<typename T, std::size_t N>
const_reverse_iterator arbb::array< T, N >::rend (  )  const

Returns a const reverse iterator to the end of a reverse traversal of this array.

template<typename T, std::size_t N>
const_iterator arbb::array< T, N >::cbegin (  )  const

Equivalent to array::begin() const, even if *this is not const.

template<typename T, std::size_t N>
const_iterator arbb::array< T, N >::cend (  )  const

Equivalent to array::end() const, even if *this is not const.

template<typename T, std::size_t N>
const_reverse_iterator arbb::array< T, N >::crbegin (  )  const

Equivalent to array::rbegin() const, even if *this is not const.

template<typename T, std::size_t N>
const_reverse_iterator arbb::array< T, N >::crend (  )  const

Equivalent to array::rend() const, even if *this is not const.

template<typename T, std::size_t N>
size_type arbb::array< T, N >::size (  )  const

Returns the number of elements contained in this array.

Always returns N.

template<typename T, std::size_t 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.

template<typename T, std::size_t N>
bool arbb::array< T, N >::empty (  )  const

Returns true if and only if this->size() == 0.

template<typename T, std::size_t N>
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.

template<typename T, std::size_t N>
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.

template<typename T, std::size_t N>
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.

template<typename T, std::size_t N>
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.

template<typename T, std::size_t N>
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.

template<typename T, std::size_t N>
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.

template<typename T, std::size_t N>
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.

template<typename T, std::size_t N>
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.

template<typename T, std::size_t N>
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.

template<typename T, std::size_t N>
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.

template<typename T, std::size_t N>
template<typename S >
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.

template<typename T, std::size_t N>
template<typename U >
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.

template<typename T, std::size_t N>
template<typename U >
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.


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

Submit feedback on this help topic

Copyright © 2010, Intel Corporation. All rights reserved.