I encourages with this problem: If I have
class A
{
public:
};
int main()
{
A a{};
A b{a};
}
gcc gives:
moves.
The class is an aggregate, so list-initialisation will perform aggregate initialisation, and won't consider the implicitly-declared constructors.
Since there are no data members, only an empty list can be a valid aggregate initialiser.
But when I use
A b(a)
instead ofA b{a}
all compiles correctly.
Direct initialisation will use the implicit constructor rather than attempting aggregate initialisation.
And if I declare default constructor it compiles too.
By declaring a constructor, the class is no longer an aggregate, and can only be initialised using a constructor.