Files
2025-10-25 03:02:53 +03:00

58 lines
1.7 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[array.creation]
# 23 Containers library [[containers]](./#containers)
## 23.3 Sequence containers [[sequences]](sequences#array.creation)
### 23.3.3 Class template array [[array]](array#creation)
#### 23.3.3.6 Array creation functions [array.creation]
[🔗](#lib:to_array)
`template<class T, size_t N>
constexpr array<remove_cv_t<T>, N> to_array(T (&a)[N]);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6344)
*Mandates*: is_array_v<T> is false andis_constructible_v<remove_cv_t<T>, T&> is true[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6349)
*Preconditions*: T meets the *Cpp17CopyConstructible* requirements[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6353)
*Returns*: {{ a[0], …, a[N - 1] }}[.](#3.sentence-1)
[🔗](#lib:to_array_)
`template<class T, size_t N>
constexpr array<remove_cv_t<T>, N> to_array(T (&&a)[N]);
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6365)
*Mandates*: is_array_v<T> is false andis_constructible_v<remove_cv_t<T>, T> is true[.](#4.sentence-1)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6370)
*Preconditions*: T meets the *Cpp17MoveConstructible* requirements[.](#5.sentence-1)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6374)
*Returns*: {{ std::move(a[0]), …, std::move(a[N - 1]) }}[.](#6.sentence-1)