C的哪些特性让模板类在没有模板参数的情况下引用自己?

鉴于:
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 <>.

表面上看,它只是一个方便的功能.

相关文章

本程序的编译和运行环境如下(如果有运行方面的问题欢迎在评...
水了一学期的院选修,万万没想到期末考试还有比较硬核的编程...
补充一下,先前文章末尾给出的下载链接的完整代码含有部分C&...
思路如标题所说采用模N取余法,难点是这个除法过程如何实现。...
本篇博客有更新!!!更新后效果图如下: 文章末尾的完整代码...
刚开始学习模块化程序设计时,估计大家都被形参和实参搞迷糊...