Export (0) Print
Expand All

array Class (STL)

Describes an object that controls a sequence of length N of elements of type Ty. The sequence is stored as an array of Ty, contained in the array<Ty, N> object.

template<class Ty, std::size_t N>
    class array;

Parameter

Description

Ty

The type of an element.

N

The number of elements.

Type Definition

Description

array::const_iterator

The type of a constant iterator for the controlled sequence.

array::const_pointer

The type of a constant pointer to an element.

array::const_reference

The type of a constant reference to an element.

array::const_reverse_iterator

The type of a constant reverse iterator for the controlled sequence.

array::difference_type

The type of a signed distance between two elements.

array::iterator

The type of an iterator for the controlled sequence.

array::pointer

The type of a pointer to an element.

array::reference

The type of a reference to an element.

array::reverse_iterator

The type of a reverse iterator for the controlled sequence.

array::size_type

The type of an unsigned distance between two elements.

array::value_type

The type of an element.

Member Function

Description

array::array

Constructs an array object.

array::assign

Replaces all elements.

array::at

Accesses an element at a specified position.

array::back

Accesses the last element.

array::begin

Designates the beginning of the controlled sequence.

array::cbegin

Returns a random-access const iterator to the first element in the array.

array::cend

Returns a random-access const iterator that points just beyond the end of the array.

array::crbegin

Returns a const iterator to the first element in a reversed array.

array::crend

Returns a const iterator to the end of a reversed array.

array::data

Gets the address of the first element.

array::empty

Tests whether elements are present.

array::end

Designates the end of the controlled sequence.

array::fill

Replaces all elements with a specified value.

array::front

Accesses the first element.

array::max_size

Counts the number of elements.

array::rbegin

Designates the beginning of the reversed controlled sequence.

array::rend

Designates the end of the reversed controlled sequence.

array::size

Counts the number of elements.

array::swap

Swaps the contents of two containers.

Operator

Description

array::operator=

Replaces the controlled sequence.

array::operator[]

Accesses an element at a specified position.

The type has a default constructor array() and a default assignment operator operator=, and satisfies the requirements for an aggregate. Therefore, objects of type array<Ty, N> can be initialized by using an aggregate initializer. For example,

    array<int, 4> ai = { 1, 2, 3 };

creates the object ai that holds four integer values, initializes the first three elements to the values 1, 2, and 3, respectively, and initializes the fourth element to 0.

Header: <array>

Namespace: std

Show:
© 2014 Microsoft