Doc. no.: | P0325R1 |
---|---|
Date: | 2016-06-29 |
Audience: | Library Working Group |
Reply-to: | Zhihao Yuan <zy at miator dot net> |
This paper proposes to adopt the “Array creation functions”[1]
in Library Fundamentals v2 into the C++ working paper, for the following reasons:
These facilities are useful, and have been replicated/reinvented in many places/codebases, also been an LWG issue since 2008[2]
, while the design adopted in TSv2 is of the least controversial among those.
The functionality is stable since the initial make_array
paper[3]
.
The wording is relative to N4594.
Copy the section 9.2.2 [container.array.creation][1]
from Library Fundamentals v2 to the IS working paper, as a new section 23.3.7.9 [array.creation] between [array.zero] and [array.tuple], and adjust 23.3.2 [array.syn] accordingly (see the adopted paper[4]
for reference).
Amend the examples in 23.3.7.9 with the following:
[Example:
int i = 1; int& ri = i;
auto a1 = make_array(i, ri); // a1 is of type array<int, 2>
auto a2 = make_array(i, ri, 42L); // a2 is of type array<long, 3>
auto a3 = make_array<long>(i, ri); // a3 is of type array<long, 2>
auto a4 = make_array<long>(); // a4 is of type array<long, 0>
auto a5 = make_array(); // ill-formed
–end example]
[1]
Array creation functions. N4564 Programming Languages – C++ Extensions for Library Fundamentals, Version 2. http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2015/n4564.pdf#page=104&zoom=auto,0,590
[2]
LWG 851 simplified array construction. http://cplusplus.github.io/LWG/lwg-active.html#851
[3]
N3824 make_array. http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2014/n3824.htm
[4]
N4391 make_array, revision 4. http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2015/n4391.html