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!
==Benefits and drawbacks of template metaprogramming== Compile-time versus execution-time tradeoffs get visible if a great deal of template metaprogramming is used. * Template metaprogramming allows the programmer to focus on architecture and delegate to the compiler the generation of any implementation required by client code. Thus, template metaprogramming can accomplish truly [[Generic programming|generic code]], facilitating code minimization and better maintainability{{Citation needed|date=June 2014}}. * With respect to C++ prior to version ''C++11'', the syntax and idioms of template metaprogramming were esoteric compared to conventional C++ programming, and template metaprograms could be very difficult to understand.<ref>{{cite web | first1 = K. | last1 = Czarnecki | first2 = J. | last2 = O'Donnell | first3 = J. | last3 = Striegnitz | first4 = Walid Mohamed | last4 = Taha | title = DSL implementation in metaocaml, template haskell, and C++ | publisher = University of Waterloo, University of Glasgow, Research Centre Julich, Rice University | year = 2004 | url = http://camlunity.ru/swap/Library/Computer%20Science/Metaprogramming/Domain-Specific%20Languages/DSL%20Implementation%20in%20MetaOCaml,%20Template%20Haskell%20and%20C++.pdf |quote=''C++ Template Metaprogramming suffers from a number of limitations, including portability problems due to compiler limitations (although this has significantly improved in the last few years), lack of debugging support or IO during template instantiation, long compilation times, long and incomprehensible errors, poor readability of the code, and poor error reporting.'' | ref = Czarnecki, O’Donnell, Striegnitz, Taha - DSL implementation in metaocaml, template haskell, and C++ }}</ref><ref>{{cite web | first1 = Tim | last1 = Sheard | authorlink2 = Simon Peyton Jones | first2 = Simon Peyton | last2 = Jones | title = Template Meta-programming for Haskell | publisher = ACM 1-58113-415-0/01/0009 | year = 2002 | url = http://research.microsoft.com/en-us/um/people/simonpj/papers/meta-haskell/meta-haskell.pdf | quote = ''Robinson’s provocative paper identifies C++ templates as a major, albeit accidental, success of the C++ language design. Despite the extremely baroque nature of template meta-programming, templates are used in fascinating ways that extend beyond the wildest dreams of the language designers. Perhaps surprisingly, in view of the fact that templates are functional programs, functional programmers have been slow to capitalize on C++’s success'' | ref = Sheard, S.P.Jones - Template Meta-programming for Haskell }}</ref> But from C++11 onward the syntax for value computation metaprogramming becomes more and more akin to "normal" C++, with less and less readability penalty.
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)