Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Template metaprogramming
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Metaprogramming technique}} {{More footnotes needed|date=June 2010}} '''Template metaprogramming''' ('''TMP''') is a [[metaprogramming]] technique in which [[Generic programming|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 can include [[compile time|compile-time]] [[constant (programming)|constant]]s, [[data structure]]s, and complete [[function (computer science)|function]]s. The use of templates can be thought of as [[Compile-time function execution|compile-time polymorphism]]. The technique is used by a number of languages, the best-known being [[C++]], but also [[Curl programming language|Curl]], [[D programming language|D]], [[Nim (programming language)|Nim]], and [[XL Programming Language|XL]]. Template metaprogramming was, in a sense, discovered accidentally.<ref name="Meyers2005">{{cite book|author=Scott Meyers|title=Effective C++: 55 Specific Ways to Improve Your Programs and Designs|url=https://books.google.com/books?id=Qx5oyB49poYC&q=%22Template+metaprogramming%22|date=12 May 2005|publisher=Pearson Education|isbn=978-0-13-270206-5}}</ref><ref>See [[wikibooks:C++ Programming/Templates/Template Meta-Programming#History of TMP|History of TMP]] on Wikibooks</ref> Some other languages support similar, if not more powerful, compile-time facilities (such as [[Lisp (programming language)|Lisp]] [[Macro (computer science)#Syntactic macros|macros]]), but those are outside the scope of this article.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)