Title
Improve the example for initializing by initializer list
Status
dr
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: 2024-03-20.01:52:37

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 (not the copy constructor)
S s3s4 = { };              // invoke #3#4
Date: 2024-03-15.00:00:00

[Accepted as a DR at the March, 2024 meeting.]

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

History
Date User Action Args
2024-04-05 21:43:46adminsetstatus: ready -> dr
2024-03-20 14:10:31adminsetstatus: tentatively ready -> ready
2023-11-16 21:27:26adminsetstatus: open -> tentatively ready
2022-10-28 19:04:44adminsetmessages: + msg6959
2022-10-26 00:00:00admincreate