The parameters for Foo have default values, therefore in main() I can do Foo(); to create a Foo and it'll have the default template arguments. However I cannot use in a template argument:
template <typename T = double, int a =2, int b = 3>
struct Foo {};
//cannot deduce template arguments for ‘Foo’ from ()
template <typename FooType = Foo()> // <-- Error
struct TemplatedStructTakingAFooType
{
};
int main()
{
Foo(); // Foo type is deduced to be default values, ie.,
//Foo<double, 2, 3>;
decltype(Foo()); // Compiler knows the type
}
In my Visual Studio compiler it highlights the area in red indicating an error, but compiles. On onlineGDB under C++17 is fails to compile with the above error. Is this allowed? Is there any reason it shouldn't be?
Edit: I realised how stupid using is as Foo() isn't a type, but neither '= Foo' nor '= decltype(Foo())' work either.