C++23: Syntactic Sugar with Deducing This -- Rainer Grimm

syntacticsugar-grimm.pngThe Curiously Recurring Template Pattern (CRTP) is a heavily used idiom in C++. It is similarly resistant to understanding as the classic design pattern visitor I presented in my last post: “C++23: Deducing This“.  Thanks to deducing this, we can remove the C and R from the abbreviation.

C++23: Syntactic Sugar with Deducing This

By Rainer Grimm

From the article:


The acronym CRTP stands for the C++ idiom Curiously Recurring Template Pattern and denotes a technique in C++ in which a class Derived is derived from a class template Base. The critical point is that Base has Derived as a template argument.

template <typename T>
class Base{

class Derived : public Base<Derived>{
CRTP is typically used to implement static polymorphism. Unlike dynamic polymorphism, static polymorphism happens at compile time and does not require an expensive run-time pointer indirection.

Add a Comment

Comments are closed.

Comments (0)

There are currently no comments on this entry.