Template Metaprogramming

Template metaprogramming is a metaprogramming technique in which templates are used by a compiler to generate temporary source code, which is merged by the compiler with the rest of the source code and then compiled. The output of these templates include compile-time constants, data structures, and complete functions. The use of templates can be thought of as compile-time execution. The technique is used by a number of languages, the best-known being C++, but also Curl, D, and XL.

Template metaprogramming was, in a sense, discovered accidentally: see History of TMP.

Some other languages support similar, if not more powerful compile-time facilities (such as Lisp macros), but those are outside the scope of this article.

Read more about Template Metaprogramming:  Components of Template Metaprogramming, Using Template Metaprogramming, Benefits and Drawbacks of Template Metaprogramming