Title
Improve the example for initializing by initializer list
Status
tentatively ready
Section
9.4.5 [dcl.init.list]
Submitter
Shafik Yaghmour

Created on 2022-10-26.00:00:00 last changed 2 weeks ago

Messages

Date: 2023-11-16.21:27:26

Proposed resolution (approved by CWG 2023-11-11):

Change the example in 9.4.5 [dcl.init.list] bullet 3.7 as follows:

struct S {
  S(std::initializer_list<double>); // #1
  S(std::initializer_list<int>);    // #2
  S(std::initializer_list<S>);      // #3
  S();                              // #3#4

  // ...
};
S s1 = { 1.0, 2.0, 3.0 };  // invoke #1
S s2 = { 1, 2, 3 };        // invoke #2
S s3{s2};                  // invoke #3 and not the copy constructor
S s3s4 = { };              // invoke #3#4
Date: 2022-10-26.00:00:00

Issue 2137 amended the rules for initialization by initializer list, but neglected to add an example.

History
Date User Action Args
2023-11-16 21:27:26adminsetstatus: open -> tentatively ready
2022-10-28 19:04:44adminsetmessages: + msg6959
2022-10-26 00:00:00admincreate