Template metaprogramming: Difference between revisions

Content deleted Content added
Dymaio (talk | contribs)
Static Table Generation: Another one-line grammatical fix
Citation bot (talk | contribs)
m Alter: template type, title. Add: date, year, citeseerx. Removed URL that duplicated unique identifier. | You can use this bot yourself. Report bugs here. | Activated by User:AManWithNoPlan | All pages linked from User:AManWithNoPlan/sandbox2 | via #UCB_webform_linked
Line 11:
The use of templates as a metaprogramming technique requires two distinct operations: a template must be defined, and a defined template must be [[Instance (computer science)|instantiated]]. The template definition describes the generic form of the generated source code, and the instantiation causes a specific set of source code to be generated from the generic form in the template.
 
Template metaprogramming is [[Turing-complete]], meaning that any computation expressible by a computer program can be computed, in some form, by a template metaprogram.<ref name=Veldhuizen2003>{{cite webdocument|last1=Veldhuizen|first1=Todd L.|title=C++ Templates are Turing Complete|url=http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.14.3670}}</ref>
 
Templates are different from ''[[Macro (computer science)#Programming macros|macros]]''. A macro is a piece of code that executes at compile time and either performs textual manipulation of code to-be compiled (e.g. [[C++]] macros) or manipulates the [[abstract syntax tree]] being produced by the compiler (e.g. [[Rust (programming language)|Rust]] or [[Lisp]] macros). Textual macros are notably more independent of the syntax of the language being manipulated, as they merely change the in-memory text of the source code right before compilation.
Line 339:
==References==
{{Reflist}}
* {{cite book | authorlink = Ulrich W. Eisenecker | first = Ulrich W. | last = Eisenecker | title = Generative Programming: Methods, Tools, and Applications | publisher = Addison-Wesley | isbn = 0-201-30977-7 | year = 2000 }}
* {{cite book | authorlink = Andrei Alexandrescu | first = Andrei | last = Alexandrescu | title = [[Modern C++ Design]]: Generic Programming and Design Patterns Applied | publisher = Addison-Wesley | isbn = 3-8266-1347-3 | year = 2003 }}
* {{cite book | authorlink1 = David Abrahams (computer programmer) | first = David | last = Abrahams | authorlink2 = Aleksey Gurtovoy | first2 = Aleksey | last2 = Gurtovoy | title = C++ Template Metaprogramming: Concepts, Tools, and Techniques from Boost and Beyond | publisher = Addison-Wesley | isbn = 0-321-22725-5 | date = January 2005 }}
* {{cite book | authorlink1 = David Vandervoorde | first1 = David | last1 = Vandervoorde | authorlink2 = Nicolai M. Josuttis | first2 = Nicolai M. | last2 = Josuttis | title = C++ Templates: The Complete Guide | publisher = Addison-Wesley | isbn = 0-201-73484-2 | year = 2003 }}
* {{cite book | authorlink = Manuel Clavel | first = Manuel | last = Clavel | title = Reflection in Rewriting Logic: Metalogical Foundations and Metaprogramming Applications | isbn = 1-57586-238-7 | date = 2000-10-16 }}
 
==External links==