Template Metaprogramming Techniques

last modified: September 27, 2014

CeePlusPlus techniques that yield compile time solutions for problems usually determined at runtime:

Implementations:

TinyTTL

Boost MPL

Template metaprogramming stores information used for compile time calculations in the type system. Partial template specicialization handles special cases. Metaprograms use metafunctions and metavariables:

Interestingly, the C++ standard allows escaping template closures and HigherOrder templates. This makes compiling a small LambdaCalculus -like language to C++ Templates nearly trivial. Unfortunately, the standard-prescribed maximal recursion depth is rather low (13 levels, I believe), but most compilers have a much larger limit, usually in the range of several hundred levels.


CategoryCppTemplates CategoryMetaprogramming


Loading...