What is it about having an aggregate public base class (or even multiple aggregate public base classes) that would make a class lose the nice properties of aggregate classes
This is the definition of an aggregate from the c++11 standard, that is really all I can give without trying to guess what the committee was thinking when they made this decision.
1 An aggregate is an array or a class (Clause 9) with no user-provided constructors (12.1), no brace-or-equal- initializers for non-static data members (9.2), no private or protected non-static data members (Clause 11), no base classes (Clause 10), and no virtual functions (10.3).
In the bold it says that an aggregate has no base classes.
As for the issue with inheritance that the other answer brings up you can make uniform initialization work with inheritance. NOTE: A is still an aggregate.
struct A {
int val_A;
};
struct B : public A {
int val_B;
B(int a, int b) : A{a}, val_B(b) {}
};
int main() {
B b {2,3};
return 0;
}
You just have give B a constructor, IMO the standard could have just as easily chosen this as the default. Aggregates were probably kept in because they were in previous standards but the truth is with c++11 features you really don't even need them. In fact one issue is that std::array
needs double braces since it has no initializer list constructor, I think this issue is solve in c++14.
I would like to add that I don't see how much being an aggregate adds to a class given the new features of uniform initialization and initializer lists.