This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of Open status.

2823. std::array initialization is still not permissive enough

Section: 21.3.7.1 [array.overview] Status: Open Submitter: Robert Haberlach Opened: 2016-11-16 Last modified: 2018-03-24

Priority: 3

View all other issues in [array.overview].

View all issues with Open status.

Discussion:

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 (9.3.1 [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.

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

[2017-01-27 Telecon]

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

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

Proposed resolution:

This wording is relative to N4606.

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

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