Doc. no.: P0325R1
Date: 2016-06-29
Audience: Library Working Group
Reply-to: Zhihao Yuan <zy at miator dot net>

Propose to adopt make_array into the IS


This paper proposes to adopt the “Array creation functions”[1] in Library Fundamentals v2 into the C++ working paper, for the following reasons:

  1. 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.

  2. 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 [array.creation] between [] and [array.tuple], and adjust 23.3.2 [array.syn] accordingly (see the adopted paper[4] for reference).

Amend the examples in with the following:


    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
auto a6 = make_array<double>(1, 2); // ill-formed: might narrow

–end example]


[1] Array creation functions. N4564 Programming Languages – C++ Extensions for Library Fundamentals, Version 2.,0,590

[2] LWG 851 simplified array construction.

[3] N3824 make_array.

[4] N4391 make_array, revision 4.