array Class (TR1)
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;
Parameters
Parameter |
Description |
Ty |
The type of an element. |
N |
The number of elements. |
Members
Type Definition |
Description |
The type of a constant iterator for the controlled sequence. |
|
The type of a constant pointer to an element. |
|
The type of a constant reference to an element. |
|
The type of a constant reverse iterator for the controlled sequence. |
|
The type of a signed distance between two elements. |
|
The type of an iterator for the controlled sequence. |
|
The type of a pointer to an element. |
|
The type of a reference to an element. |
|
The type of a reverse iterator for the controlled sequence. |
|
The type of an unsigned distance between two elements. |
|
The type of an element. |
Member Function |
Description |
Constructs an array object. |
|
Replaces all elements. |
|
Accesses an element at a specified position. |
|
Accesses the last element. |
|
Designates the beginning of the controlled sequence. |
|
Returns a random-access const iterator to the first element in the array. |
|
Returns a random-access const iterator that points just beyond the end of the array. |
|
Returns a const iterator to the first element in a reversed array. |
|
Returns a const iterator to the end of a reversed array. |
|
Gets the address of the first element. |
|
Tests whether elements are present. |
|
Designates the end of the controlled sequence. |
|
Replaces all elements with a specified value. |
|
Accesses the first element. |
|
Counts the number of elements. |
|
Designates the beginning of the reversed controlled sequence. |
|
Designates the end of the reversed controlled sequence. |
|
Counts the number of elements. |
|
Swaps the contents of two containers. |
Operator |
Description |
Replaces the controlled sequence. |
|
Accesses an element at a specified position. |
Remarks
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.
Requirements
Header: <array>
Namespace: std