Template meta-programming: Why you must get it

C++ is a language suited with a widespread set of tools, paradigms, idioms. Nobody denies that C++ is a complex language to learn, but it’s a shame that most C++ programmers keep one of its most powerful features out of the toolbox, just categorizing it as bizarre black magic.

Of course I'm talking about templates and template meta-programming.


We have a template system far more capable than simple generics. A system which, when well understood, can do almost anything: Simple type specialization, compile-time computing, code generation, zero overhead DSELs, etc. Even C++ evolved to get more of that TMP as first-class features of the language in the last recent years, see <type_traits> adoption from Boost, and that ongoing and widely accepted range library proposal which hides a little and ready to use metaprogramming library inside.


But such powerful TMP capabilities are usually reserved for a little group of enlightened C++ devs, who managed to learn the complex TMP techniques to deal with large generic libraries and their idiosyncrasies, such as STL implementers, Boost maintainers, etc.

This talk is not intended as a master class about template metaprogramming. My goal is to show you how TMP can help in everyday coding. From simple examples about type correctness checking, to complex use cases about compile-time data initialization.


TMP is not for STL programmers only. Neither that hard when you try to get it.

Speaker: Manuel Sanchez

Slides: Template meta-programming: Why you must get it

Go back