X Tutup
The Wayback Machine - https://web.archive.org/web/20210119093851/https://en.cppreference.com/w/cpp/language/crtp
Namespaces
Variants
Views
Actions

Curiously Recurring Template Pattern

From cppreference.com
< cpp‎ | language

The Curiously Recurring Template Pattern is an idiom in which a class X derives from a class template Y, taking a template parameter Z, where Y is instantiated with Z=X. For example,

template<class Z>
class Y
{
};
 
class X : public Y<X>
{
};


[edit] See also

allows an object to create a shared_ptr referring to itself
(class template) [edit]
helper class template for defining views, using the curiously recurring template pattern
(class template) [edit]
X Tutup