Curiously recurring template pattern: Difference between revisions

Content deleted Content added
m Example: wikilinking VTBL
m minor tweaks
Line 1:
In [[software engineering]], theThe '''curiously recurring template pattern''' ('''CRTP'''), is a [[software design patternC++]] whereidiom in which a [[base class]] [[genericX programming|template]]derives isfrom instantiateda withclass atemplate [[derivedinstantiation class]]using typeX itself as its template parameterargument. The name of thethis patternidiom was coined by Coplien{{ref|Coplien}}, who had observed it in some of the earliest [[C++]] template code.
 
==Example==
Line 8:
};
 
Typically, the base class template will take advantage of the fact that member function bodies (definitions) are not instantiated until long after their declarations, and will use members of the derived class within its own member functions, via the use of a <code>static_cast</code>, e.g.:
 
template <class Derived>