Curiously Recurring Template Pattern
Curiously Recurring Template Pattern
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
.
CRTP may be used to implement "compile-time polymorphism", when a base class exposes an interface, and derived classes implement such interface.
1 2 3 4 |
|
1 2 3 4 5 6 7 |
|
1 2 |
|
1 2 3 |
|