Template Class array

Class Documentation

template <class T, std::size_t N>
class array

Fixed size distributed array.

Section 21.3.7.1 of the C++ standard defines the ::array as a fixed-size sequence of objects. An ::array should be a contiguous container (as defined in section 21.2.1). According to that definition, contiguous containers requires contiguous iterators. The definition of contiguous iterators implies contiguous memory allocation for the sequence, and it cannot be guaranteed in many distributed settings. Therefore, ::array relaxes this requirement.

Template Parameters
  • T: The type of the elements in the distributed array.
  • N: The number of element in the distributed array.

Public Types

template<>
using value_type = typename array_t::value_type
template<>
using size_type = typename array_t::size_type

The type used to represent size.

template<>
using difference_type = typename array_t::difference_type

The type used to represent distances.

template<>
using reference = typename array_t::reference

The type of references to the element in the array.

template<>
using const_reference = typename array_t::const_reference

The type for const references to element in the array.

template<>
using pointer = typename array_t::pointer

The type for pointer to ::value_type.

template<>
using const_pointer = typename array_t::const_pointer

The type for pointer to ::const_value_type.

template<>
using iterator = typename array_t::iterator

The type of iterators on the array.

template<>
using const_iterator = typename array_t::const_iterator

The type of const iterators on the array.

Public Functions

array()

Constructor.

~array()

Destructor.

array<T, N> &operator=(const array<T, N> &O)

The copy assignment operator.

Return
A reference to the left-hand side.
Parameters
  • O: The right-hand side of the operator.

constexpr reference operator[](size_type n)

Unchecked element access operator.

Return
a ::reference to the n-th element in the array.

constexpr const_reference operator[](size_type n) const

Unchecked element access operator.

Return
a ::const_reference to the n-th element in the array.

constexpr reference at(size_type n)

Checked element access operator.

Return
a ::reference to the n-th element in the array.

constexpr const_reference at(size_type n) const

Checked element access operator.

Return
a ::const_reference to the n-th element in the array.

constexpr reference front()

the first element in the array.

Return
a ::reference to the element in position 0.

constexpr const_reference front() const

the first element in the array.

Return
a ::const_reference to the element in position 0.

constexpr reference back()

the last element in the array.

Return
a ::reference to the element in position N - 1.

constexpr const_reference back() const

the last element in the array.

Return
a ::const_reference to the element in position N - 1.

constexpr iterator begin()
constexpr const_iterator begin() const

The iterator to the beginning of the sequence.

Return
a ::const_iterator to the beginning of the sequence.

constexpr iterator end()

The iterator to the end of the sequence.

Return
an ::iterator to the end of the sequence.

constexpr const_iterator end() const

The iterator to the end of the sequence.

Return
a ::const_iterator to the end of the sequence.

constexpr const_iterator cbegin() const

The iterator to the beginning of the sequence.

Return
a ::const_iterator to the beginning of the sequence.

constexpr const_iterator cend() const

The iterator to the end of the sequence.

Return
a ::const_iterator to the end of the sequence.

constexpr bool empty() const
constexpr size_type size() const

The size of the container.

Return
the size of the container (N).

constexpr size_type max_size() const

The maximum size of the container.

Return
the maximum size of the container (N).

void fill(const value_type &v)
void swap(array<T, N> &O)

Swap the content of two array.

Parameters
  • O: The array to swap the content with.