I came across this example from cppreference:
...
struct T3
{
int mem1;
std::string mem2;
T3() {} // user-provided default constructor
}
...
This example clearly show that the given constructor is user-provided constructor since it's not explicitly defaulted or deleted on its first declaration; per [dcl.fct.def.default]/5:
[..] A function is user-provided if it is user-declared and not explicitly defaulted or deleted on its first declaration [..]
Now, Per [dcl.init.aggr]/1
An aggregate is an array or a class (Clause 11) with
- (1.1) — no user-declared or inherited constructors (11.4.5),
- (1.2) — no private or protected direct non-static data members (11.8),
- (1.3) — no virtual functions (11.7.3), and
- (1.4) — no virtual, private, or protected base classes (11.7.2).
It seems that my class satisfy all the above requirements to be an aggregate including the point (1.1) since the given constructor is not user-declared.
So why the following code it ill-formed (tested on g++12.2 with c++20 flag):
static_assert(std::is_aggregate<T3>::value); // fail
Why static assertion is failed?