This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 109b. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2022-09-25


1232. Creation of array temporaries using a braced-init-list

Section: 9.4.5  [dcl.init.list]     Status: C++11     Submitter: Andrew Koenig     Date: 2011-01-03

[Voted into the WP at the March, 2011 meeting as part of paper N3262.]

By analogy with the variable definition

    int arr[3] = {1, 2, 3};

it should be possible to write something like

   void f(const int(&)[3]);
   void g() {
     f({1, 2, 3});
   }

There are currently at least two problems with the latter usage. First, the variable initializer relies on brace elision, which appears to be defined only for variable declarations (9.4.2 [dcl.init.aggr] paragraph 11) , and possibly only for certain forms of variable declarations.

Second, the call would require creation of an array temporary to which the parameter reference would be bound, and the current Standard does not describe array temporaries (although rvalue arrays can occur as members of class rvalues). This is also contrary to the direction established by CWG in considering 1058.