Template trickery

Template wizardry was a landmark of C++ for a long time. After it was accidentally discovered that templates constitute a Turing complete language of their own, their usage exploded. Unfortunately, it was a very verbose and ugly language that was close to being incomprehensible. Today, the tricks of olden days have been largely replaced by more sane constructs from the newer C++ standards, but the templates still have their place in C++.

We will look now at some classic template techniques which were used to improve performance. As this book is neither an introductory C++ text nor a template metaprogramming primer, we assume that the reader can read basic template syntax.