C++ Curiously Recurring Template Pattern
根据维基百科的定义:
A class X derives from a class template instantiation using X itself as template argument.
它的一般形式如下:
A class X
derives from a class template instantiation using X
itself as template argument.
template <class T>
class Base
{
// methods within Base can use template to access members of Derived
};
class Derived : public Base<Derived>
{
// ...
};
应用1:Counting Objects
相关文献: