Title
std::array initialization is still not permissive enough
Status
open
Section
[array.overview]
Submitter
Robert Haberlach

Created on 2016-11-16.00:00:00 last changed 82 months ago

Messages

Date: 2018-03-19.00:12:24

Proposed resolution:

This wording is relative to N4606.

  1. Change [array.overview] p2 as indicated:

    -2- An array is an aggregate ([dcl.init.aggr]) that can be list-initialized with up to N elements whose types are convertiblethat can be implicitly converted to T.

Date: 2018-03-14.00:00:00

[ 2018-3-14 Wednesday evening issues processing; priority to 3; move to Open ]

Jens: There's nothing you can do about the double braces in std::array. That's a core thing.

STL to write paper to resolve this.

Date: 2017-01-27.00:00:00

[ 2017-01-27 Telecon ]

Priority 2; consensus is that the P/R is not quite right.

Date: 2016-11-15.00:00:00

[ 2016-11-26, Tim Song comments ]

This is not possible as written, because due to the brace elision rules for aggregate initialization, std::array<int, 2> arr{{0}, {1}}; will never work: the {0} is taken as initializing the inner array, and the {1} causes an error.

Date: 2016-11-16.00:00:00

LWG 2590's resolution is incomplete:

std::array<int, 1> arr{{0}};

should be fine, but isn't guaranteed, since {0} has no type. We should rather go for implicit conversion:

An array is an aggregate ([dcl.init.aggr]) that can be list-initialized with up to N elements whose types are convertible to Tthat can be implicitly converted to T.

History
Date User Action Args
2018-03-19 00:12:24adminsetmessages: + msg9762
2018-03-19 00:12:24adminsetstatus: new -> open
2017-01-30 15:17:53adminsetmessages: + msg8800
2016-11-26 21:23:46adminsetmessages: + msg8693
2016-11-26 20:38:46adminsetmessages: + msg8692
2016-11-16 00:00:00admincreate