bja*_*d_e 5 c++ language-lawyer template-argument-deduction c++17
template <typename>
struct Foo {
template <typename T>
struct Bar {
Bar(T val):
val_(val)
{
}
T val_;
};
};
auto func() {
return Foo<int>::Bar(3);
}
Run Code Online (Sandbox Code Playgroud)
在clang中似乎需要一个额外的推导指南,以便编译:
template <typename>
struct Foo {
template <typename T>
struct Bar {
Bar(T val):
val_(val)
{
}
T val_;
};
template <typename T>
Bar(T) -> Bar<T>; // deduction guide
};
auto func() {
return Foo<int>::Bar(3);
}
Run Code Online (Sandbox Code Playgroud)
这个额外要求背后有什么理由吗?或者只是对标准中不清楚的东西的解释有所不同?
| 归档时间: |
|
| 查看次数: |
77 次 |
| 最近记录: |