对于这两种情况,您将其称为成员模板.
template<typename T>
struct A {
// this is not a template
void f();
// but this is a member template
template<typename T> void g();
};
Run Code Online (Sandbox Code Playgroud)
它是一个成员模板,因为它是一个模板成员.成员函数f不是模板,而是类模板的成员函数.在C++中,遗憾的是这个术语没有明确的术语,因此在标准中制定某些规则以应用模板,但也适用于类模板的成员函数.许多规则需要招募所有喜欢的组合
function template
member function of class template
member function of nested class of a class template
member function template
...
Run Code Online (Sandbox Code Playgroud)
同样适用于类模板的成员类.已经提出调用成员函数/类模板temploid或类似的东西.但是,正在努力解决这种状况.
| 归档时间: |
|
| 查看次数: |
188 次 |
| 最近记录: |