Title
Aggregates with empty base classes
Status
extension
Section
11.6.1 [dcl.init.aggr]
Submitter
Gabriel Dos Reis

Created on 2012-09-29.00:00:00 last changed 93 months ago

Messages

Date: 2012-10-15.00:00:00

Rationale (October, 2012):

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

Date: 2012-09-29.00:00:00

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

With the inclusion of aggregate initialization in list-initialization, the consequence of this decision could be surprising, so it should be reexamined. 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 being well-formed but #2 being ill-formed.

History
Date User Action Args
2012-11-03 00:00:00adminsetmessages: + msg4192
2012-09-29 00:00:00admincreate