[array.overview]

# 23 Containers library [[containers]](./#containers)

## 23.3 Sequence containers [[sequences]](sequences#array.overview)

### 23.3.3 Class template array [[array]](array#overview)

#### 23.3.3.1 Overview [array.overview]

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6108)

The header [<array>](array.syn#header:%3carray%3e "23.3.2 Header <array> synopsis [array.syn]") defines a class template for storing fixed-size
sequences of objects[.](#1.sentence-1)

An array is a [contiguous container](container.reqmts#def:container,contiguous "23.2.2.2 Container requirements [container.reqmts]")[.](#1.sentence-2)

An instance of array<T, N> stores N elements of type T,
so that size() == N is an invariant[.](#1.sentence-3)

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6116)

An array is an [aggregate](dcl.init.aggr#def:aggregate "9.5.2 Aggregates [dcl.init.aggr]") that can be
list-initialized with up
to N elements whose types are convertible to T[.](#2.sentence-1)

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6123)

An array meets all of the requirements
of a container ([[container.reqmts]](container.reqmts "23.2.2.2 Container requirements")) and
of a reversible container ([[container.rev.reqmts]](container.rev.reqmts "23.2.2.3 Reversible container requirements")),
except that a default
constructed array object is not empty if N>0[.](#3.sentence-1)

An array meets some of the requirements of a[sequence container](sequence.reqmts "23.2.4 Sequence containers [sequence.reqmts]")[.](#3.sentence-2)

Descriptions are provided here
only for operations on array that are not described in
one of these tables and
for operations where there is additional semantic information[.](#3.sentence-3)

[4](#4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6137)

array<T, N> is a structural type ([[temp.param]](temp.param#term.structural.type "13.2 Template parameters")) ifT is a structural type[.](#4.sentence-1)

Two values a1 and a2 of type array<T, N> are [template-argument-equivalent](temp.type#def:template-argument-equivalent "13.6 Type equivalence [temp.type]") if and only if
each pair of corresponding elements in a1 and a2 are template-argument-equivalent[.](#4.sentence-2)

[5](#5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6145)

The types iterator and const_iterator meet
the [constexpr iterator](iterator.requirements.general#def:iterator,constexpr "24.3.1 General [iterator.requirements.general]") requirements[.](#5.sentence-1)

[ð](#lib:array)

namespace std {template<class T, size_t N>struct array {// typesusing value_type = T; using pointer = T*; using const_pointer = const T*; using reference = T&; using const_reference = const T&; using size_type = size_t; using difference_type = ptrdiff_t; using iterator = *implementation-defined*; // see [[container.requirements]](container.requirements "23.2 Requirements")using const_iterator = *implementation-defined*; // see [[container.requirements]](container.requirements "23.2 Requirements")using reverse_iterator = std::reverse_iterator<iterator>; using const_reverse_iterator = std::reverse_iterator<const_iterator>; // no explicit construct/copy/destroy for aggregate typeconstexpr void fill(const T& u); constexpr void swap(array&) noexcept(is_nothrow_swappable_v<T>); // iteratorsconstexpr iterator begin() noexcept; constexpr const_iterator begin() const noexcept; constexpr iterator end() noexcept; constexpr const_iterator end() const noexcept; constexpr reverse_iterator rbegin() noexcept; constexpr const_reverse_iterator rbegin() const noexcept; constexpr reverse_iterator rend() noexcept; constexpr const_reverse_iterator rend() const noexcept; constexpr const_iterator cbegin() const noexcept; constexpr const_iterator cend() const noexcept; constexpr const_reverse_iterator crbegin() const noexcept; constexpr const_reverse_iterator crend() const noexcept; // capacityconstexpr bool empty() const noexcept; constexpr size_type size() const noexcept; constexpr size_type max_size() const noexcept; // element accessconstexpr reference operator[](size_type n); constexpr const_reference operator[](size_type n) const; constexpr reference at(size_type n); // freestanding-deletedconstexpr const_reference at(size_type n) const; // freestanding-deletedconstexpr reference front(); constexpr const_reference front() const; constexpr reference back(); constexpr const_reference back() const; constexpr T* data() noexcept; constexpr const T* data() const noexcept; }; template<class T, class... U> array(T, U...) -> array<T, 1 + sizeof...(U)>;}
