In C++17 I am allowed to use Foo
in the following example without empty template argument brackets thanks to class template argument deduction:
template<typename T = int>
struct Foo{};
int main(){
Foo f; // before C++17 you had to write "Foo<> f;"
}
Why am I not allowed to use the same syntax for class members?
template<typename T = int>
struct Foo{};
struct Foo2{
Foo f{}; ///< error: invalid use of template-name 'Foo' without an argument list
};
int main(){
Foo2 f2;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With