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;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.