Namespaces
Variants
Views
Actions

Template Metaprogramming

From cppreference.com
< cpp‎ | language


Template metaprogramming is a family of techniques to create new types and compute values at compile time. C++ templates are Turing complete if there are no limits to the amount of recursive instantiations and the number of allowed state variables. Erwin Unruh was the first to demonstrate template metaprogramming at a committee meeting by instructing the compiler to print out prime numbers in error messages. The standard recommends an implementation support at least 1024 levels of recursive instantiation, and infinite recursion in template instantiations is undefined behavior.

External links

1.  David Vandevoorde, Nicolai M. Josuttis, Douglas Gregor (2017), C++ Templates - The Complete Guide, 2nd Edition.
2.  Wikibook: Template Meta-Programming.
3.  Wikipedia: Template Meta-Programming.