Now that we’re clear on how the CRTP works, let me share with you another technique involving templates that is complementary to the CRTP: Mixin classes. I learnt about mixin classes by watching Arthur O’Dwyer’s Template Normal Programming talk at CppCon (actually you can find them in the slides because they were skipped over during the presentation). I find […]
Why doesn’t C++ allow partial specialization on function templates? Such was the question I asked to you, readers of Fluent C++, in the post covering Template Partial Specialization. Not because I wanted to test you, but simply because I couldn’t find the answer. And oh boy did I get an answer. The post received comments, questions, […]
Today I want to share something about the right way to emulate partial function template specialisation in C++. I learnt it by watching Arthur O’Dwyer’s CppCon talk Template Normal Programming. Actually, the technique for emulating function template partial specialization through class template specialization is well known, but the naming convention used by Arthur is the […]
In this final episode of the series on the Curiously Recuring Template Pattern, let’s see an implementation that makes it easier to write CRTP classes. In case you missed an episode in the series, here they are: The CRTP, episode One: Definition The CRTP, episode Two: What the CRTP can bring to your code The CRTP, episode […]
After having defined the basics on the CRTP in episode #1 of the series, let’s now consider how the CRTP can be helpful in day-to-day code. The episodes in this series are: The CRTP, episode One: Definition The CRTP, episode Two: What the CRTP can bring to your code The CRTP, episode Three: An implementation helper for […]
The Curiously Recurring Template Pattern (CRTP) is a C++ idiom whose name was coined by James Coplien in 1995, in early C++ template code. The “C” in CRTP made it travel the years in the C++ community by being this: a Curiosity. We often find definitions of what CRTP is, and it is indeed an […]