Created on 2016-11-07.00:00:00 last changed 55 months ago
[ 2017-06-02 Issues Telecon ]
Leave status as LEWG; priority 3
Previous resolution [SUPERSEDED]:This wording is relative to N4600.
Add the following signature to [header.array.synop]:
// 9.2.2, Array creation functions template <class D = void, class... Types> constexpr array<VT, sizeof...(Types)> make_array(Types&&... t); template <class T, size_t N> constexpr array<remove_cv_t<T>, N> to_array(T (&a)[N]); template <class T, size_t N> constexpr array<remove_cv_t<T>, N> to_array(T (&&a)[N]);Modify [container.array.creation] as follows:
template <class T, size_t N> constexpr array<remove_cv_t<T>, N> to_array(T (&a)[N]); template <class T, size_t N> constexpr array<remove_cv_t<T>, N> to_array(T (&&a)[N]);-6- Returns: For all i, 0 ≤ i < N, a
An array<remove_cv_t<T>, N>such that each element is copy-initialized with the corresponding element of ainitialized with { a[i]... } for the first form, or { std::move(a[i])... } for the second form..
[ 2017-02 in Kona, LEWG responds ]
Would like a small paper; see examples before and after. How does this affect overload resolution?
[ Issues Telecon 16-Dec-2016 ]
Status to LEWG
Addresses: fund.ts.v2
C++ doesn't have a prvalue expression of array type, but rvalue arrays can still come from different kinds of sources:
C99 compound literals (int[]) {2, 4},
std::move(arr),
Deduction to_array<int const>({ 2, 4 }).
See also CWG 1591: Deducing array bound and element type from initializer list.
For 3), users are "abusing" to_array to get access to uniform initialization to benefit from initializing elements through braced-init-list and/or better narrowing conversion support.
We should just add rvalue reference support to to_array.History | |||
---|---|---|---|
Date | User | Action | Args |
2020-05-10 11:23:30 | admin | set | messages: + msg11284 |
2020-05-10 11:23:30 | admin | set | status: lewg -> resolved |
2017-06-05 15:41:21 | admin | set | messages: + msg9228 |
2017-06-05 15:41:21 | admin | set | messages: + msg9227 |
2016-12-16 20:56:38 | admin | set | messages: + msg8745 |
2016-12-16 20:56:38 | admin | set | status: new -> lewg |
2016-11-13 14:10:49 | admin | set | messages: + msg8633 |
2016-11-07 00:00:00 | admin | create |