When is a private constructor not a private constructor?

The trick is in C++14 8.4.2/5 [dcl.fct.def.default]:

… A function is user-provided if it is user-declared and not explicitly defaulted or
deleted on its first declaration. …

Which means that C‘s default constructor is actually not user-provided, because it was explicitly defaulted on its first declaration. As such, C has no user-provided constructors and is therefore an aggregate per 8.5.1/1 [dcl.init.aggr]:

An aggregate is an array or a class (Clause 9) with no user-provided constructors (12.1), no private or
protected non-static data members (Clause 11), no base classes (Clause 10), and no virtual functions (10.3).

Leave a Comment