I have found that the possibility of usage of initializer list syntax for a class depends on whether or not the class fields have default values. Why?
To be precise, consider the following code:
class S
{
public:
int a;
};
...
int a;
S s{ a };
It compiles without any problems. But if I add a default value to the class field, it stops building:
class S
{
public:
int a = 0;
};
...
int a;
S s{ a };
Error 1 error C2440: 'initializing' : cannot convert from 'initializer-list' to 'S'
Why? What else influences such constructor generation?