Title
Creation of array temporaries using a braced-init-list
Status
c++11
Section
9.4.5 [dcl.init.list]
Submitter
Andrew Koenig

Created on 2011-01-03.00:00:00 last changed 130 months ago

Messages

Date: 2011-03-15.00:00:00

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

Date: 2011-01-03.00:00:00

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.

History
Date User Action Args
2014-03-03 00:00:00adminsetstatus: fdis -> c++11
2011-04-10 00:00:00adminsetmessages: + msg3351
2011-04-10 00:00:00adminsetstatus: open -> fdis
2011-01-03 00:00:00admincreate