I have the following class definition. I included a private x
to make sure it is not an aggregate.
class A {
private:
int x;
public:
A() = delete;
A(std::initializer_list<int>) { printf("init\n"); }
};
Now if I initialize this object with A a = A{}
, it will say A::A()
is deleted. I guess it is trying to call A::A()
but it is deleted. If I comment out that line, so A::A()
is automatically generated. Then if I run this code, I could see that it is calling A::A(std::initializer_list<int>)
!
And more confusing, if I define A() = default
, the initialization calls A::A()
again.
Can anyone point me to the right direction of understading this behavior? Thanks!
I'm using G++ 6.3.0 with flag -std=c++17
.