Movatterモバイル変換


[0]ホーム

URL:


Issue 1561 - WG21 CWG Issues
Title
Aggregates with empty base classes
Status
cd4
Section
9.5.2 [dcl.init.aggr]
Submitter
Gabriel Dos Reis

Created on2012-09-29.00:00:00 last changed43 months ago

Messages

msg4192 (view)
Date: 2012-10-15.00:00:00

Rationale (October, 2012):

CWG felt that this language design question would be betterconsidered by EWG.

msg4191 (view)
Date: 2016-02-15.00:00:00

[Accepted at the February, 2016 meeting as part of paper P0017R1.]

The definition of an aggregate class 9.5.2 [dcl.init.aggr]was originally intended to include only C-like classes because properC++ classes were expected to encapsulate data members and useconstructors for initialization. Consequently, classes with baseswere excluded from being aggregates.

With the inclusion of aggregate initialization in list-initialization,the consequence of this decision could be surprising, so it should bereexamined. For example,

  struct A {    int& val;  };  struct B { };  struct C : B {    int& val;  };  int main() {    int i = 0;    A a { i } ;         // #1    C c { i } ;         // #2    return 0;  }

it is not clear that there is a good rationale for #1 beingwell-formed but #2 being ill-formed.

History
DateUserActionArgs
2022-04-28 06:39:30adminsetstatus: extension -> cd4
2012-11-03 00:00:00adminsetmessages: +msg4192
2012-09-29 00:00:00admincreate

[8]ページ先頭

©2009-2025 Movatter.jp