鉴于:
template <typename T>
class C {
C & operator ++ () { ... }
};
为什么/如何允许C声明类型C的变量和函数而不是命名C< T>?在使用许多参数来模拟“自我类型”不方便的模板之前,我还没有真正考虑过它.
我应该知道这有什么怪癖吗?
解决方法
[n3290: 14.6.1/1]: Like normal (non-template) classes,class templates have an injected-class-name (Clause 9). The injected-class-name can be used as a template-name or a type-name. When it is used with a template-argument-list,as a template-argument for a template template-parameter,or as the final identifier in the elaborated-type-specifier of a friend class template declaration,it refers to the class template itself. Otherwise,it is equivalent to the template-name followed by the template-parameters of the class template enclosed in <> .
表面上看,它只是一个方便的功能.
(编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|