Template metaprogramming: Difference between revisions

Content deleted Content added
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
Compile-time class generation: Add information on consteval from C++20
Line 51:
To be able to use templates in this manner, the compiler must know the value of its parameters at compile time, which has the natural precondition that factorial<X>::value can only be used if X is known at compile time. In other words, X must be a constant literal or a constant expression.
 
In [[C++11]] and [[C++20]], [[constexpr]], aand consteval were wayintroduced to let the compiler execute simple constant expressions, was addedcode. Using constexpr and consteval, one can use the usual recursive factorial definition with the non-templated syntax.<ref>http://www.cprogramming.com/c++11/c++11-compile-time-processing-with-constexpr.html</ref>
 
==Compile-time code optimization==