【发布时间】:2012-09-22 12:52:10
【问题描述】:
根据此页面: http://womble.decadent.org.uk/c++/template-faq.html#non-dependent “非依赖名称是那些被认为不依赖于模板参数的名称,加上模板本身的名称和在其中声明的名称(成员、朋友和局部变量)”
这似乎得到了以下代码被认为是有效的事实的支持(LLVM/Comeau)
template<typename T>
struct Template
{
typedef int I;
typedef Template::I Type; // 'Template' is NOT dependent
typedef Template<T>::I Type2; // 'Template<T>' is NOT dependent
Template<T>* m;
void f()
{
m->f(); // 'm' is NOT dependent
}
};
花了一些时间阅读 C++ 98 标准后,我找不到指定此行为的位置。我希望在“temp.nondep”下找到对此的提及。
【问题讨论】:
-
注意,从 C++11 开始,现在有一堆语言涉及“名称指的是 当前实例化 if”,这涉及到这种用法。
标签: c++ templates name-lookup dependent-name c++98