Why does having a base class disqualify a class from being aggregate?

后端 未结 3 1883
醉酒成梦
醉酒成梦 2021-01-17 15:57

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

3条回答
  •  旧时难觅i
    2021-01-17 16:23

    According to http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3308.pdf

    Despite the clear intentions of the standard, type B is not a literal type:

    struct A {}; struct B : A {};
    

    This is because its constructor is not implicitly defined until it is odr-used, and until that point it has no constexpr constructors.

    Honestly not sure what this means, though.

提交回复
热议问题