Type of initializer_list backing array
9.4.5 [dcl.init.list]
Johannes Schaub

Created on 2011-11-19.00:00:00 last changed 87 months ago


Date: 2012-10-15.00:00:00

[Moved to DR at the October, 2012 meeting.]

Date: 2012-02-15.00:00:00

Proposed resolution (February, 2012):

Change 9.4.5 [dcl.init.list] paragraph 5 as follows:

An object of type std::initializer_list<E> is constructed from an initializer list as if the implementation allocated an array of N elements of type const E, where N is the number of elements in the initializer list. Each element of that array is copy-initialized with the corresponding element of the initializer list, and the std::initializer_list<E> object is constructed to refer to that array. If a narrowing conversion is required to initialize any of the elements, the program is ill-formed. [Example:

  struct X {
    X(std::initializer_list<double> v);
  X x{ 1,2,3 };

The initialization will be implemented in a way roughly equivalent to this:

  const double __a[3] = {double{1}, double{2}, double{3}};
  X x(std::initializer_list<double>(__a, __a+3));

assuming that the implementation can construct an initializer_list object with a pair of pointers. —end example]

Date: 2011-11-19.00:00:00

According to 9.4.5 [dcl.init.list] paragraph 5, the elements of the backing array for an object of type std::initializer_list<E> are of type E. This is contradicted by the wording of 17.10 [support.initlist] paragraph 2.

Date User Action Args
2014-03-03 00:00:00adminsetstatus: drwp -> cd3
2013-05-03 00:00:00adminsetstatus: dr -> drwp
2012-11-03 00:00:00adminsetmessages: + msg4149
2012-11-03 00:00:00adminsetstatus: ready -> dr
2012-02-27 00:00:00adminsetmessages: + msg3724
2012-02-27 00:00:00adminsetstatus: open -> ready
2011-11-19 00:00:00admincreate