All posts in "Templates"

Mixin Classes: The Yang of the CRTP

Published December 12, 2017 - 2 Comments
Mixin classes CRTP

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 […]

Function Templates Partial Specialization in C++

Published August 15, 2017 - 8 Comments

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, […]

Template Partial Specialization In C++

Published August 11, 2017 - 4 Comments

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 […]

The Curiously Recurring Template Pattern (CRTP)

Published May 12, 2017 - 11 Comments
CRTP definition curiously recurring recursive template pattern

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 […]