std::array
(C++17) | ||||
Sequence | ||||
(C++11) | ||||
(C++26) | ||||
(C++26) | ||||
(C++11) | ||||
Associative | ||||
Unordered associative | ||||
(C++11) | ||||
(C++11) | ||||
(C++11) | ||||
(C++11) | ||||
Adaptors | ||||
(C++23) | ||||
(C++23) | ||||
(C++23) | ||||
(C++23) | ||||
Views | ||||
(C++20) | ||||
(C++23) | ||||
Tables | ||||
Iterator invalidation | ||||
Member function table | ||||
Non-member function table |
Member types | ||||||
Member functions | ||||||
Non-member functions | ||||||
| ||||||
Helper classes | ||||||
Deduction guides(C++17) |
Defined in header <array> | ||
template<class T,class...U> array( T, U...)-> array<T,1+ sizeof...(U)>; | (since C++17) | |
Onededuction guide is provided forstd::array to provide an equivalent ofstd::experimental::make_array for construction ofstd::array
from avariadic parameter pack.
The program is ill-formed if(std::is_same_v<T, U>&& ...) is not true. Note that(std::is_same_v<T, U>&& ...) is true whensizeof...(U) is zero.
#include <algorithm>#include <array>#include <cassert>#include <type_traits> int main(){constint x=10;std::array a{1,2,3,5, x};// OK, creates std::array<int, 5>assert(a.back()== x); // std::array b{1, 2u}; // Error, all arguments must have the same type // std::array<short> c{3, 2, 1}; // Error, wrong number of template argsstd::array c{std::to_array<short>({3,2,1})};// C++20 facilityassert(std::ranges::equal(c,std::array{3,2,1})); static_assert(std::is_same_v<short, decltype(c)::value_type>);}