I can't quite figure out why this code doesn't compile on Visual Studio 2019 (16.8.3):
#include <initializer_list>
struct Foo
{
Foo(std::initializer_list<int> = {});
};
int main()
{
Foo f;
}
Foo::Foo(std::initializer_list<int>) {}
It gives me this error:
C2512: "Foo": no appropriate default constructor available
Is this a compiler bug or am I missing something here? Note that I've checked and this does compile on GCC 10.1
If you change the forward declaration of the constructor to an immediate definition the code compiles without errors:
#include <initializer_list>
struct Foo
{
Foo(std::initializer_list<int> = {}) {}
};
int main()
{
Foo f;
}