Polymorphism, Rethought at Compile-Time

In this article, we will explain how the features of C++23 are revolutionizing the philosophy of static polymorphism. We will also take this opportunity to give you an exclusive look at a new pattern inspired by the latest discoveries in the field.

Origins and History of the CRTP

First of all, it would be relevant to clarify what the Curiously Recurring Template Pattern (CRTP), or commonly called CRTP, is. CRTP is a technique that consists of simulating the behavior of virtual polymorphism exclusively at compile-time.

This technique was formalized in 1989 under the name F-bounded polymorphism. The term CRTP was independently coined by Jim Coplien in 1995 after he observed it multiple times in different codebases of that era.