[英]Class template argument deduction of member variables
在C ++ 17中,由於類模板參數推導,我可以在以下示例中使用Foo
而不使用空模板參數括號:
template<typename T = int>
struct Foo{};
int main(){
Foo f; // before C++17 you had to write "Foo<> f;"
}
為什么我不允許對類成員使用相同的語法?
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;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.