<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.sarg.dev/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=2605%3A8D80%3A13E0%3AE0D0%3A2DE3%3A913E%3A61B7%3A51CC</id>
	<title>Vero - Wikipedia - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.sarg.dev/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=2605%3A8D80%3A13E0%3AE0D0%3A2DE3%3A913E%3A61B7%3A51CC"/>
	<link rel="alternate" type="text/html" href="https://wiki.sarg.dev/index.php/Special:Contributions/2605:8D80:13E0:E0D0:2DE3:913E:61B7:51CC"/>
	<updated>2026-08-14T20:09:00Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.44.2</generator>
	<entry>
		<id>https://wiki.sarg.dev/index.php?title=Standard_library&amp;diff=236571</id>
		<title>Standard library</title>
		<link rel="alternate" type="text/html" href="https://wiki.sarg.dev/index.php?title=Standard_library&amp;diff=236571"/>
		<updated>2025-10-10T05:50:45Z</updated>

		<summary type="html">&lt;p&gt;2605:8D80:13E0:E0D0:2DE3:913E:61B7:51CC: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Short description|Library provided with a programming language to provide common services}}&lt;br /&gt;
{{refimprove|date=May 2019}}&lt;br /&gt;
&lt;br /&gt;
In [[computer programming]], a &#039;&#039;&#039;standard library&#039;&#039;&#039; is the [[library (computing)|library]] made available across [[Programming language implementation|implementations]] of a [[programming language]]. Often, a standard library is specified by its associated [[programming language specification]], however, some are set in part or whole by more informal practices of a language community.&lt;br /&gt;
&lt;br /&gt;
Some languages define a core part of the standard library that must be made available in all implementations while allowing other parts to be implemented optionally. &lt;br /&gt;
&lt;br /&gt;
In many languages, the standard library often has its own namespace. For example, [[C++]], [[D (programming language)|D]], and [[Rust (programming language)|Rust]] use &amp;lt;code&amp;gt;std::*&amp;lt;/code&amp;gt; as the standard library namespace. [[C Sharp (programming language)|C#]] uses &amp;lt;code&amp;gt;System.*&amp;lt;/code&amp;gt;, while [[Java (programming language)|Java]] uses &amp;lt;code&amp;gt;java.*&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;javax.*&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;jdk.*&amp;lt;/code&amp;gt;. However, in some like [[Python (programming language)|Python]] and [[Go (programming language)|Go]], there is no &amp;quot;standard library namespace&amp;quot; or common prefix for modules belonging to the standard library.&lt;br /&gt;
&lt;br /&gt;
As defined with the core language aspects, the line between the core language and its standard library is relatively subtle. A [[programmer]] may confuse the two aspects even though the language designers intentionally separate the two.&lt;br /&gt;
&lt;br /&gt;
The line between the core language and its standard library is further blurred in some languages by defining core language constructs in terms of its standard library. For example, [[Java (programming language)|Java]] defines a [[string literal]] as an instance of the &amp;lt;code&amp;gt;java.lang.String&amp;lt;/code&amp;gt; class. [[Smalltalk]] defines an anonymous function expression (a &amp;quot;block&amp;quot;) as an instance of its library&#039;s &amp;lt;code&amp;gt;BlockContext&amp;lt;/code&amp;gt; class. [[Scheme (programming language)|Scheme]] does not specify which portions must be implemented as core language vs. standard library.&lt;br /&gt;
&lt;br /&gt;
==Contents==&lt;br /&gt;
Depending on the constructs available in the core language, a standard library may include:&lt;br /&gt;
&lt;br /&gt;
*[[Subroutine]]s&lt;br /&gt;
*[[Macro (computer science)|Macro]] definitions&lt;br /&gt;
*[[Global variable]]s&lt;br /&gt;
*[[Class (computer science)|Class]] definitions&lt;br /&gt;
*[[Template (C++)|Templates]]&lt;br /&gt;
&lt;br /&gt;
Commonly provided functionality includes:&lt;br /&gt;
&lt;br /&gt;
*[[Algorithm]]s; such as [[sorting algorithm]]s&lt;br /&gt;
*[[Data structure]]s; such as [[list (computing)|list]], [[tree (data structure)|tree]], and [[hash table]]&lt;br /&gt;
*Interaction with external systems; input/output&lt;br /&gt;
*Interaction with the host [[operating system]]&lt;br /&gt;
&lt;br /&gt;
==Philosophies==&lt;br /&gt;
Philosophies of standard library design vary widely. For example, [[Bjarne Stroustrup]], designer of [[C++]], writes:&lt;br /&gt;
{{quote|What ought to be in the standard C++ library? One ideal is for a programmer to be able to find every interesting, significant, and reasonably general class, function, template, etc., in a library. However, the question here is not, &amp;quot;What ought to be in &#039;&#039;some&#039;&#039; library?&amp;quot; but &amp;quot;What ought to be in the &#039;&#039;standard&#039;&#039; library?&amp;quot; The answer &amp;quot;Everything!&amp;quot; is a reasonable first approximation to an answer to the former question but not the latter. A standard library is something every implementer must supply so that every programmer can rely on it.&amp;lt;ref&amp;gt;Bjarne Stroustrup. &#039;&#039;The C++ Programming Language&#039;&#039;. 3rd Ed. Addison-Wesley, 1997&amp;lt;/ref&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
This suggests a relatively small standard library, containing only the constructs that &amp;quot;every programmer&amp;quot; might reasonably require when building a large collection of software. This is the philosophy that is used in the [[C (programming language)|C]] and [[C++]] standard libraries. As a result, the [[C Standard Library]] and [[C++ Standard Library]] are significantly smaller in size and scope compared to, for instance, the [[Java Class Library|Java standard library]] and [[Standard Libraries (CLI)|C# standard library]], which feature more extensive abilities.&lt;br /&gt;
&lt;br /&gt;
By contrast, [[Guido van Rossum]], designer of [[Python (programming language)|Python]], has embraced a much more inclusive vision of the standard library. Python attempts to offer an easy-to-code, object-oriented, high-level language.{{cn|date=April 2024}} In the Python tutorial, he writes:&lt;br /&gt;
{{quote|Python has a &amp;quot;batteries included&amp;quot; philosophy. This is best seen through the sophisticated and robust capabilities of its larger packages.&amp;lt;ref&amp;gt;Guido van Rossum. [https://docs.python.org/3/tutorial/stdlib.html#batteries-included].&amp;lt;/ref&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Van Rossum goes on to list libraries for processing [[XML]], [[XML-RPC]], [[Email|email messages]], and localization, facilities that the C++ standard library omits. This other philosophy is often found in [[scripting language]]s (as in [[Python (programming language)|Python]] or [[Ruby (programming language)|Ruby]]) or languages that use a [[virtual machine]], such as [[Java (programming language)|Java]] or the [[.NET Framework]] languages. In C++, such facilities are not part of the standard library, but instead are included in other libraries, such as [[Boost (C++ libraries)|Boost]] or [[POCO C++ Libraries|POCO]]. In Java, the formerly standard libraries [[Java Platform, Enterprise Edition]] (now Jakarta EE) and [[JavaFX]] were moved to separate independent libraries.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
{{list|date=November 2016}}&lt;br /&gt;
&lt;br /&gt;
*[[C standard library]]&lt;br /&gt;
*[[C++ standard library]]&lt;br /&gt;
*[[ .NET Framework|.NET]] [[Framework Class Library]] (FCL)&lt;br /&gt;
*[[Java Class Library]] (JCL)&lt;br /&gt;
*[[Rust (programming language)|Rust]] [https://doc.rust-lang.org/std/ standard library]&lt;br /&gt;
*[[Factor (programming language)|Factor]] [http://docs.factorcode.org/content/article-handbook-library-reference.html standard library]&lt;br /&gt;
*[[Ruby (programming language)|Ruby]] [https://docs.ruby-lang.org/en/master/standard_library_md.html standard library]&lt;br /&gt;
*[[Python (programming language)|Python]] [https://docs.python.org/3/library/ standard library]&lt;br /&gt;
*[[Common Language Infrastructure]] (CLI) [[Standard Libraries (CLI)|standard libraries]]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Programming libraries]]&lt;br /&gt;
[[Category:Programming language standards]]&lt;/div&gt;</summary>
		<author><name>2605:8D80:13E0:E0D0:2DE3:913E:61B7:51CC</name></author>
	</entry>
	<entry>
		<id>https://wiki.sarg.dev/index.php?title=Template_metaprogramming&amp;diff=139006</id>
		<title>Template metaprogramming</title>
		<link rel="alternate" type="text/html" href="https://wiki.sarg.dev/index.php?title=Template_metaprogramming&amp;diff=139006"/>
		<updated>2025-10-10T04:42:14Z</updated>

		<summary type="html">&lt;p&gt;2605:8D80:13E0:E0D0:2DE3:913E:61B7:51CC: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Short description|Metaprogramming technique}}&lt;br /&gt;
{{More footnotes needed|date=June 2010}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Template metaprogramming&#039;&#039;&#039; (&#039;&#039;&#039;TMP&#039;&#039;&#039;) 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]].&lt;br /&gt;
&lt;br /&gt;
Template metaprogramming was, in a sense, discovered accidentally.&amp;lt;ref name=&amp;quot;Meyers2005&amp;quot;&amp;gt;{{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&amp;amp;q=%22Template+metaprogramming%22|date=12 May 2005|publisher=Pearson Education|isbn=978-0-13-270206-5}}&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;See [[wikibooks:C++ Programming/Templates/Template Meta-Programming#History of TMP|History of TMP]] on Wikibooks&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==Components of template metaprogramming==&lt;br /&gt;
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 generic form of the generated source code is described in the template definition, and when the template is instantiated, the generic form in the template is used to generate a specific set of source code.&lt;br /&gt;
&lt;br /&gt;
Template metaprogramming is [[Turing-complete]], meaning that any computation expressible by a computer program can be computed, in some form, by a template metaprogram.&amp;lt;ref name=Veldhuizen2003&amp;gt;{{cite CiteSeerX|last1=Veldhuizen|first1=Todd L.|title=C++ Templates are Turing Complete|year=2003|citeseerx=10.1.1.14.3670}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Templates are different from &#039;&#039;[[Macro (computer science)#Programming macros|macros]]&#039;&#039;. 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 (programming language)|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.&lt;br /&gt;
&lt;br /&gt;
Template metaprograms have no [[Immutable object|mutable variables]]&amp;amp;mdash; that is, no variable can change value once it has been initialized, therefore template metaprogramming can be seen as a form of [[functional programming]]. In fact many template implementations implement flow control only through [[Recursion (computer science)|recursion]], as seen in the example below.&lt;br /&gt;
&lt;br /&gt;
===Using template metaprogramming===&lt;br /&gt;
Though the syntax of template metaprogramming is usually very different from the programming language it is used with, it has practical uses. Some common reasons to use templates are to implement generic programming (avoiding sections of code which are similar except for some minor variations) or to perform automatic compile-time optimization such as doing something once at compile time rather than every time the program is run — for instance, by having the compiler unroll loops to eliminate jumps and loop count decrements whenever the program is executed.&lt;br /&gt;
&lt;br /&gt;
==Compile-time class generation==&lt;br /&gt;
What exactly &amp;quot;programming at compile-time&amp;quot; means can be illustrated with an example of a factorial function, which in non-template C++ can be written using recursion as follows:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=cpp&amp;gt;&lt;br /&gt;
unsigned int factorial(unsigned int n) {&lt;br /&gt;
	return n == 0 ? 1 : n * factorial(n - 1); &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// Usage examples:&lt;br /&gt;
// factorial(0) would yield 1;&lt;br /&gt;
// factorial(4) would yield 24.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The code above will execute at run time to determine the factorial value of the literals &amp;lt;code&amp;gt;0&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;4&amp;lt;/code&amp;gt;.&lt;br /&gt;
By using template metaprogramming and template specialization to provide the ending condition for the recursion, the factorials used in the program—ignoring any factorial not used—can be calculated at compile time by this code:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=cpp&amp;gt;&lt;br /&gt;
template &amp;lt;unsigned N&amp;gt;&lt;br /&gt;
struct Factorial {&lt;br /&gt;
	static constexpr unsigned value = N * Factorial&amp;lt;N - 1&amp;gt;::value;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
template &amp;lt;&amp;gt;&lt;br /&gt;
struct Factorial&amp;lt;0&amp;gt; {&lt;br /&gt;
	static constexpr unsigned value = 1;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
// Usage examples:&lt;br /&gt;
// Factorial&amp;lt;0&amp;gt;::value would yield 1;&lt;br /&gt;
// Factorial&amp;lt;4&amp;gt;::value would yield 24.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The code above calculates the factorial value of the literals &amp;lt;code&amp;gt;0&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;4&amp;lt;/code&amp;gt; at compile time and uses the results as if they were precalculated constants.&lt;br /&gt;
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 &amp;lt;code&amp;gt;Factorial&amp;lt;X&amp;gt;::value&amp;lt;/code&amp;gt; can only be used if &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; is known at compile time. In other words, &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; must be a constant literal or a constant expression.&lt;br /&gt;
&lt;br /&gt;
In [[C++11]] and [[C++20]], [[constexpr]] and consteval were introduced to let the compiler execute code. Using {{code|constexpr}} and {{code|consteval}}, one can use the usual recursive factorial definition with the non-templated syntax.&amp;lt;ref&amp;gt;{{Cite web|url=https://www.cprogramming.com/c++11/c++11-compile-time-processing-with-constexpr.html|title=Constexpr - Generalized Constant Expressions in C++11 - Cprogramming.com|website=www.cprogramming.com}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Compile-time code optimization==&lt;br /&gt;
{{see also|Compile-time function execution}}&lt;br /&gt;
The factorial example above is one example of compile-time code optimization in that all factorials used by the program are pre-compiled and injected as numeric constants at compilation, saving both run-time overhead and [[memory footprint]]. It is, however, a relatively minor optimization.&lt;br /&gt;
&lt;br /&gt;
As another, more significant, example of compile-time [[loop unrolling]], template metaprogramming can be used to create length-&#039;&#039;n&#039;&#039; vector classes (where &#039;&#039;n&#039;&#039; is known at compile time). The benefit over a more traditional length-&#039;&#039;n&#039;&#039; vector is that the loops can be unrolled, resulting in very optimized code. As an example, consider the addition operator. A length-&#039;&#039;n&#039;&#039; vector addition might be written as&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
template &amp;lt;int Length&amp;gt;&lt;br /&gt;
ColumnVector&amp;lt;Length&amp;gt;&amp;amp; ColumnVector&amp;lt;Length&amp;gt;::operator+=(const Vector&amp;lt;Length&amp;gt;&amp;amp; rhs)  {&lt;br /&gt;
    for (int i = 0; i &amp;lt; Length; ++i) {&lt;br /&gt;
        value[i] += rhs.value[i];&lt;br /&gt;
    }&lt;br /&gt;
    return *this;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When the compiler instantiates the function template defined above, the following code may be produced:{{citation needed|date=October 2015}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
template &amp;lt;&amp;gt;&lt;br /&gt;
ColumnVector&amp;lt;2&amp;gt;&amp;amp; ColumnVector&amp;lt;2&amp;gt;::operator+=(const ColumnVector&amp;lt;2&amp;gt;&amp;amp; rhs)  {&lt;br /&gt;
    value[0] += rhs.value[0];&lt;br /&gt;
    value[1] += rhs.value[1];&lt;br /&gt;
    return *this;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The compiler&#039;s optimizer should be able to unroll the &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt; loop because the template parameter &amp;lt;code&amp;gt;Length&amp;lt;/code&amp;gt; is a constant at compile time.&lt;br /&gt;
&lt;br /&gt;
However, take care and exercise caution as this may cause code bloat as separate unrolled code will be generated for each &#039;N&#039;(vector size) you instantiate with.&lt;br /&gt;
&lt;br /&gt;
==Static polymorphism==&lt;br /&gt;
[[Type polymorphism|Polymorphism]] is a common standard programming facility where derived objects can be used as instances of their base object but where the derived objects&#039; methods will be invoked, as in this code&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
class Base {&lt;br /&gt;
public:&lt;br /&gt;
    virtual void method() { &lt;br /&gt;
        std::println(&amp;quot;Base&amp;quot;); &lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    virtual ~Base() {}&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
class Derived : public Base {&lt;br /&gt;
public:&lt;br /&gt;
    virtual void method() { &lt;br /&gt;
        std::println(&amp;quot;Derived&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
int main() {&lt;br /&gt;
    Base* pBase = new Derived;&lt;br /&gt;
    pBase-&amp;gt;method(); // outputs &amp;quot;Derived&amp;quot;&lt;br /&gt;
    delete pBase;&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
where all invocations of &amp;lt;code&amp;gt;virtual&amp;lt;/code&amp;gt; methods will be those of the most-derived class. This &#039;&#039;dynamically polymorphic&#039;&#039; behaviour is (typically) obtained by the creation of [[vtable|virtual look-up table]]s for classes with virtual methods, tables that are traversed at run time to identify the method to be invoked. Thus, &#039;&#039;run-time polymorphism&#039;&#039; necessarily entails execution overhead (though on modern architectures the overhead is small).&lt;br /&gt;
&lt;br /&gt;
However, in many cases the polymorphic behaviour needed is invariant and can be determined at compile time. Then the [[Curiously Recurring Template Pattern]] (CRTP) can be used to achieve &#039;&#039;&#039;static polymorphism&#039;&#039;&#039;, which is an imitation of polymorphism in programming code but which is resolved at compile time and thus does away with run-time virtual-table lookups. For example: &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
template &amp;lt;class Child&amp;gt;&lt;br /&gt;
struct Base {&lt;br /&gt;
    void myMethod() {&lt;br /&gt;
         // ...&lt;br /&gt;
         static_cast&amp;lt;Child*&amp;gt;(this)-&amp;gt;myImplementation();&lt;br /&gt;
         // ...&lt;br /&gt;
    }&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
struct Derived : Base&amp;lt;Derived&amp;gt; {&lt;br /&gt;
     void myImplementation() {&lt;br /&gt;
         // ...&lt;br /&gt;
     }&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Here the base class template will take advantage of the fact that member function bodies are not instantiated until after their declarations, and it will use members of the derived class within its own member functions, via the use of a &amp;lt;code&amp;gt;static_cast&amp;lt;/code&amp;gt;, thus at compilation generating an object composition with polymorphic characteristics. As an example of real-world usage, the CRTP is used in the [[Boost library|Boost]] [[iterator]] library.&amp;lt;ref&amp;gt;{{Cite web|url=http://www.boost.org/libs/iterator/doc/iterator_facade.html|title = Iterator Facade - 1.79.0}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Another similar use is the &amp;quot;[[Barton–Nackman trick]]&amp;quot;, sometimes referred to as &amp;quot;restricted template expansion&amp;quot;, where common functionality can be placed in a base class that is used not as a contract but as a necessary component to enforce conformant behaviour while minimising code redundancy.&lt;br /&gt;
&lt;br /&gt;
== Static Table Generation ==&lt;br /&gt;
&lt;br /&gt;
The benefit of static tables is the replacement of &amp;quot;expensive&amp;quot; calculations with a simple array indexing operation (for examples, see [[lookup table]]). In C++, there exists more than one way to generate a static table at compile time. The following listing shows an example of creating a very simple table by using recursive structs and [[variadic templates]].&lt;br /&gt;
The table has a size of ten. Each value is the square of the index.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
import std;&lt;br /&gt;
&lt;br /&gt;
using std::array;&lt;br /&gt;
&lt;br /&gt;
constexpr int TABLE_SIZE = 10;&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Variadic template for a recursive helper struct.&lt;br /&gt;
 */&lt;br /&gt;
template &amp;lt;int Index = 0, int... D&amp;gt;&lt;br /&gt;
struct Helper : Helper&amp;lt;Index + 1, D..., Index * Index&amp;gt; { };&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Specialization of the template to end the recursion when the table size reaches TABLE_SIZE.&lt;br /&gt;
 */&lt;br /&gt;
template &amp;lt;int... D&amp;gt;&lt;br /&gt;
struct Helper&amp;lt;TABLE_SIZE, D...&amp;gt; {&lt;br /&gt;
    static constexpr array&amp;lt;int, TABLE_SIZE&amp;gt; table = { D... };&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
constexpr array&amp;lt;int, TABLE_SIZE&amp;gt; TABLE = Helper&amp;lt;&amp;gt;::table;&lt;br /&gt;
&lt;br /&gt;
enum class Numbers {&lt;br /&gt;
    FOUR = TABLE[2] // compile time use&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
int main() {&lt;br /&gt;
    for (int i: TABLE) {&lt;br /&gt;
        std::println(&amp;quot;{}&amp;quot;, i); // run time use&lt;br /&gt;
    }&lt;br /&gt;
    std::println(&amp;quot;FOUR: {}&amp;quot;, Numbers::FOUR);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The idea behind this is that the struct Helper recursively inherits from a struct with one more template argument (in this example calculated as Index * Index) until the specialization of the template ends the recursion at a size of 10 elements. The specialization simply uses the variable argument list as elements for the array.&lt;br /&gt;
The compiler will produce code similar to the following (taken from clang called with -Xclang -ast-print -fsyntax-only).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
using std::array;&lt;br /&gt;
&lt;br /&gt;
template &amp;lt;int Index = 0, int... D&amp;gt; &lt;br /&gt;
struct Helper : Helper&amp;lt;Index + 1, D..., Index * Index&amp;gt; {};&lt;br /&gt;
template &amp;lt;&amp;gt; &lt;br /&gt;
struct Helper&amp;lt;0, &amp;lt;&amp;gt;&amp;gt; : Helper&amp;lt;0 + 1, 0 * 0&amp;gt; {};&lt;br /&gt;
template &amp;lt;&amp;gt; &lt;br /&gt;
struct Helper&amp;lt;1, &amp;lt;0&amp;gt;&amp;gt; : Helper&amp;lt;1 + 1, 0, 1 * 1&amp;gt; {};&lt;br /&gt;
template &amp;lt;&amp;gt; &lt;br /&gt;
struct Helper&amp;lt;2, &amp;lt;0, 1&amp;gt;&amp;gt; : Helper&amp;lt;2 + 1, 0, 1, 2 * 2&amp;gt; {};&lt;br /&gt;
template &amp;lt;&amp;gt; &lt;br /&gt;
struct Helper&amp;lt;3, &amp;lt;0, 1, 4&amp;gt;&amp;gt; : Helper&amp;lt;3 + 1, 0, 1, 4, 3 * 3&amp;gt; {};&lt;br /&gt;
template &amp;lt;&amp;gt; &lt;br /&gt;
struct Helper&amp;lt;4, &amp;lt;0, 1, 4, 9&amp;gt;&amp;gt; : Helper&amp;lt;4 + 1, 0, 1, 4, 9, 4 * 4&amp;gt; {};&lt;br /&gt;
template &amp;lt;&amp;gt; &lt;br /&gt;
struct Helper&amp;lt;5, &amp;lt;0, 1, 4, 9, 16&amp;gt;&amp;gt; : Helper&amp;lt;5 + 1, 0, 1, 4, 9, 16, 5 * 5&amp;gt; {};&lt;br /&gt;
template &amp;lt;&amp;gt; &lt;br /&gt;
struct Helper&amp;lt;6, &amp;lt;0, 1, 4, 9, 16, 25&amp;gt;&amp;gt; : Helper&amp;lt;6 + 1, 0, 1, 4, 9, 16, 25, 6 * 6&amp;gt; {};&lt;br /&gt;
template &amp;lt;&amp;gt; &lt;br /&gt;
struct Helper&amp;lt;7, &amp;lt;0, 1, 4, 9, 16, 25, 36&amp;gt;&amp;gt; : Helper&amp;lt;7 + 1, 0, 1, 4, 9, 16, 25, 36, 7 * 7&amp;gt; {};&lt;br /&gt;
template &amp;lt;&amp;gt; &lt;br /&gt;
struct Helper&amp;lt;8, &amp;lt;0, 1, 4, 9, 16, 25, 36, 49&amp;gt;&amp;gt; : Helper&amp;lt;8 + 1, 0, 1, 4, 9, 16, 25, 36, 49, 8 * 8&amp;gt; {};&lt;br /&gt;
template &amp;lt;&amp;gt; &lt;br /&gt;
struct Helper&amp;lt;9, &amp;lt;0, 1, 4, 9, 16, 25, 36, 49, 64&amp;gt;&amp;gt; : Helper&amp;lt;9 + 1, 0, 1, 4, 9, 16, 25, 36, 49, 64, 9 * 9&amp;gt; {};&lt;br /&gt;
template &amp;lt;&amp;gt; &lt;br /&gt;
struct Helper&amp;lt;10, &amp;lt;0, 1, 4, 9, 16, 25, 36, 49, 64, 81&amp;gt;&amp;gt; {&lt;br /&gt;
    static constexpr array&amp;lt;int, TABLE_SIZE&amp;gt; TABLE = {0, 1, 4, 9, 16, 25, 36, 49, 64, 81};&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since C++17 this can be more readably written as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt; &lt;br /&gt;
import std;&lt;br /&gt;
&lt;br /&gt;
using std::array;&lt;br /&gt;
&lt;br /&gt;
constexpr int TABLE_SIZE = 10;&lt;br /&gt;
&lt;br /&gt;
constexpr array&amp;lt;int, TABLE_SIZE&amp;gt; TABLE = []() -&amp;gt; array&amp;lt;int, TABLE_SIZE&amp;gt; {&lt;br /&gt;
    array&amp;lt;int, TABLE_SIZE&amp;gt; a = {};&lt;br /&gt;
    for (size_t i = 0; i &amp;lt; TABLE_SIZE; i++) {&lt;br /&gt;
        a[i] = i * i;&lt;br /&gt;
    }&lt;br /&gt;
    return a;&lt;br /&gt;
}();&lt;br /&gt;
&lt;br /&gt;
enum class Numbers {&lt;br /&gt;
    FOUR = TABLE[2] // compile time use&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
int main() {&lt;br /&gt;
    for (int i: TABLE) {&lt;br /&gt;
        std::println(&amp;quot;{}&amp;quot;, i); // run time use&lt;br /&gt;
    }&lt;br /&gt;
    std::println(&amp;quot;FOUR: {}&amp;quot;, Numbers::FOUR);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To show a more sophisticated example the code in the following listing has been extended to have a helper for value calculation (in preparation for more complicated computations), a table specific offset and a template argument for the type of the table values (e.g. {{code|uint8_t}}, {{code|uint16_t}}, ...). &lt;br /&gt;
                                                                                    &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;                                                                &lt;br /&gt;
import std;&lt;br /&gt;
&lt;br /&gt;
using std::array;&lt;br /&gt;
&lt;br /&gt;
constexpr int TABLE_SIZE = 20;&lt;br /&gt;
constexpr int OFFSET = 12;&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Template to calculate a single table entry&lt;br /&gt;
 */&lt;br /&gt;
template &amp;lt;typename ValueType , ValueType Offset, ValuType Index&amp;gt;&lt;br /&gt;
struct ValueHelper {&lt;br /&gt;
    static constexpr ValueType VALUE = Offset + Index * Index;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Variadic template for a recursive helper struct.&lt;br /&gt;
 */&lt;br /&gt;
template&amp;lt;typename ValueType, ValueType Offset, int N = 0, ValueType... D&amp;gt;&lt;br /&gt;
struct Helper : Helper&amp;lt;ValueType, Offset, N + 1, D..., ValueHelper&amp;lt;ValueType, Offset, N&amp;gt;::VALUE&amp;gt; { };&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Specialization of the template to end the recursion when the table size reaches TABLE_SIZE.&lt;br /&gt;
 */&lt;br /&gt;
template&amp;lt;typename ValueType, ValueType Offset, ValueType... D&amp;gt;&lt;br /&gt;
struct Helper&amp;lt;ValueType, Offset, TABLE_SIZE, D...&amp;gt; {&lt;br /&gt;
    static constexpr array&amp;lt;ValueType, TABLE_SIZE&amp;gt; TABLE = { D... };&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
constexpr array&amp;lt;uint16_t, TABLE_SIZE&amp;gt; TABLE = Helper&amp;lt;uint16_t, OFFSET&amp;gt;::TABLE;&lt;br /&gt;
&lt;br /&gt;
int main() {&lt;br /&gt;
    for (int i: TABLE) {&lt;br /&gt;
        std::println(&amp;quot;{}&amp;quot;, i);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Which could be written as follows using C++17:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
import std;&lt;br /&gt;
&lt;br /&gt;
using std::array;&lt;br /&gt;
&lt;br /&gt;
constexpr int TABLE_SIZE = 20;&lt;br /&gt;
constexpr int OFFSET = 12;&lt;br /&gt;
&lt;br /&gt;
template &amp;lt;typename ValueType, int Offset&amp;gt;&lt;br /&gt;
constexpr array&amp;lt;ValueType, TABLE_SIZE&amp;gt; TABLE = []() -&amp;gt; array&amp;lt;ValueType, TABLE_SIZE&amp;gt; {&lt;br /&gt;
    array&amp;lt;ValueType, TABLE_SIZE&amp;gt; A = {};&lt;br /&gt;
    for (size_t i = 0; i &amp;lt; TABLE_SIZE; i++) {&lt;br /&gt;
        a[i] = Offset + i * i;&lt;br /&gt;
    }&lt;br /&gt;
    return A;&lt;br /&gt;
}();&lt;br /&gt;
&lt;br /&gt;
int main() {&lt;br /&gt;
    for (int i: TABLE&amp;lt;uint16_t, OFFSET&amp;gt;) {&lt;br /&gt;
        std::pritnln(&amp;quot;{}&amp;quot;, i);&lt;br /&gt;
    }&lt;br /&gt;
}                                              &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Concepts==&lt;br /&gt;
The C++20 standard brought C++ programmers a new tool for meta template programming, concepts.&amp;lt;ref&amp;gt;{{Cite web|url=https://en.cppreference.com/w/cpp/language/constraints|title=Constraints and concepts (since C++20) - cppreference.com|website=en.cppreference.com}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Concepts (C++)|Concepts]] allow programmers to specify requirements for the type, to make instantiation of template possible. The compiler looks for a template with the concept that has the highest requirements.&lt;br /&gt;
&lt;br /&gt;
Here is an example of the famous [[Fizz buzz]] problem solved with Template Meta Programming.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
import std;&lt;br /&gt;
import boost.type_index; // for pretty printing of types&lt;br /&gt;
&lt;br /&gt;
using std::tuple;&lt;br /&gt;
using boost::typeindex::type_id;&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Type representation of words to print&lt;br /&gt;
 */&lt;br /&gt;
struct Fizz {};&lt;br /&gt;
struct Buzz {};&lt;br /&gt;
struct FizzBuzz {};&lt;br /&gt;
template &amp;lt;size_t M&amp;gt; &lt;br /&gt;
struct Number {&lt;br /&gt;
    constexpr static size_t N = M; &lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Concepts used to define condition for specializations&lt;br /&gt;
 */&lt;br /&gt;
template &amp;lt;typename A&amp;gt; &lt;br /&gt;
concept HasN = requires { &lt;br /&gt;
    requires A::N - A::N == 0; &lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
template &amp;lt;typename A&amp;gt; &lt;br /&gt;
concept FizzConc = HasN&amp;lt;A&amp;gt; &amp;amp;&amp;amp; requires { &lt;br /&gt;
    requires A::N % 3 == 0; &lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
template &amp;lt;typename A&amp;gt; &lt;br /&gt;
concept BuzzConc = HasN&amp;lt;A&amp;gt; &amp;amp;&amp;amp; requires { &lt;br /&gt;
    requires A::N % 5 == 0;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
template &amp;lt;typename A&amp;gt; &lt;br /&gt;
concept FizzBuzzC = FizzConc&amp;lt;A&amp;gt; &amp;amp;&amp;amp; BuzzConc&amp;lt;A&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * By specializing `res` structure, with concepts requirements, proper instantiation is performed&lt;br /&gt;
 */&lt;br /&gt;
template &amp;lt;typename X&amp;gt; &lt;br /&gt;
struct Res;&lt;br /&gt;
&lt;br /&gt;
template &amp;lt;FizzBuzzConc X&amp;gt; &lt;br /&gt;
struct Res&amp;lt;X&amp;gt; { &lt;br /&gt;
    using Result = FizzBuzz; &lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
template &amp;lt;FizzConc X&amp;gt; &lt;br /&gt;
struct Res&amp;lt;X&amp;gt; { &lt;br /&gt;
    using Result = Fizz; &lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
template &amp;lt;BuzzConc X&amp;gt; &lt;br /&gt;
struct Res&amp;lt;X&amp;gt; { &lt;br /&gt;
    using Result = Buzz; &lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
template &amp;lt;HasN X&amp;gt; &lt;br /&gt;
struct Res&amp;lt;X&amp;gt; { &lt;br /&gt;
    using Result = X; &lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Predeclaration of concatenator&lt;br /&gt;
 */&lt;br /&gt;
template &amp;lt;size_t Concat, typename... Args&amp;gt; &lt;br /&gt;
struct Concatenator;&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Recursive way of concatenating next types&lt;br /&gt;
 */&lt;br /&gt;
template &amp;lt;size_t Concat, typename ... Args&amp;gt;&lt;br /&gt;
struct Concatenator&amp;lt;Concat, tuple&amp;lt;Args...&amp;gt;&amp;gt; { &lt;br /&gt;
    using Type = typename Concatenator&amp;lt;Concat - 1, tuple&amp;lt; typename Res&amp;lt;Number&amp;lt;Concat&amp;gt;&amp;gt;::Result, Args...&amp;gt;&amp;gt;::Type;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Base case&lt;br /&gt;
 */&lt;br /&gt;
template &amp;lt;typename... Args&amp;gt; &lt;br /&gt;
struct Concatenator&amp;lt;0, tuple&amp;lt;Args...&amp;gt;&amp;gt; { &lt;br /&gt;
    using Type = tuple&amp;lt;Args...&amp;gt;;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Final result getter&lt;br /&gt;
 */&lt;br /&gt;
template &amp;lt;size_t Amount&amp;gt;&lt;br /&gt;
using FizzBuzzFull = typename Concatenator&amp;lt;Amount - 1, tuple&amp;lt;typename Res&amp;lt;Number&amp;lt;Amount&amp;gt;&amp;gt;::Result&amp;gt;&amp;gt;::Type;&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char* argv[]) {&lt;br /&gt;
	// printing result using boost.type_index, so it&#039;s clear&lt;br /&gt;
    std::println(&amp;quot;{}&amp;quot;, type_id&amp;lt;fizz_buzz_full_template&amp;lt;100&amp;gt;&amp;gt;().pretty_name());&lt;br /&gt;
}&lt;br /&gt;
/*&lt;br /&gt;
Result:&lt;br /&gt;
	std::tuple&amp;lt;Number&amp;lt;1ul&amp;gt;, Number&amp;lt;2ul&amp;gt;, Fizz, Number&amp;lt;4ul&amp;gt;, Buzz, Fizz, Number&amp;lt;7ul&amp;gt;, Number&amp;lt;8ul&amp;gt;, Fizz, Buzz, Number&amp;lt;11ul&amp;gt;, Fizz, Number&amp;lt;13ul&amp;gt;, Number&amp;lt;14ul&amp;gt;, FizzBuzz, Number&amp;lt;16ul&amp;gt;, Number&amp;lt;17ul&amp;gt;, Fizz, Number&amp;lt;19ul&amp;gt;, Buzz, Fizz, Number&amp;lt;22ul&amp;gt;, Number&amp;lt;23ul&amp;gt;, Fizz, Buzz, Number&amp;lt;26ul&amp;gt;, Fizz, Number&amp;lt;28ul&amp;gt;, Number&amp;lt;29ul&amp;gt;, FizzBuzz, Number&amp;lt;31ul&amp;gt;, Number&amp;lt;32ul&amp;gt;, Fizz, Number&amp;lt;34ul&amp;gt;, Buzz, Fizz, Number&amp;lt;37ul&amp;gt;, Number&amp;lt;38ul&amp;gt;, Fizz, Buzz, Number&amp;lt;41ul&amp;gt;, Fizz, Number&amp;lt;43ul&amp;gt;, Number&amp;lt;44ul&amp;gt;, FizzBuzz, Number&amp;lt;46ul&amp;gt;, Number&amp;lt;47ul&amp;gt;, Fizz, Number&amp;lt;49ul&amp;gt;, Buzz, Fizz, Number&amp;lt;52ul&amp;gt;, Number&amp;lt;53ul&amp;gt;, Fizz, Buzz, Number&amp;lt;56ul&amp;gt;, Fizz, Number&amp;lt;58ul&amp;gt;, Number&amp;lt;59ul&amp;gt;, FizzBuzz, Number&amp;lt;61ul&amp;gt;, Number&amp;lt;62ul&amp;gt;, Fizz, Number&amp;lt;64ul&amp;gt;, Buzz, Fizz, Number&amp;lt;67ul&amp;gt;, Number&amp;lt;68ul&amp;gt;, Fizz, Buzz, Number&amp;lt;71ul&amp;gt;, Fizz, Number&amp;lt;73ul&amp;gt;, Number&amp;lt;74ul&amp;gt;, FizzBuzz, Number&amp;lt;76ul&amp;gt;, Number&amp;lt;77ul&amp;gt;, Fizz, Number&amp;lt;79ul&amp;gt;, Buzz, Fizz, Number&amp;lt;82ul&amp;gt;, Number&amp;lt;83ul&amp;gt;, Fizz, Buzz, Number&amp;lt;86ul&amp;gt;, Fizz, Number&amp;lt;88ul&amp;gt;, Number&amp;lt;89ul&amp;gt;, FizzBuzz, Number&amp;lt;91ul&amp;gt;, Number&amp;lt;92ul&amp;gt;, Fizz, Number&amp;lt;94ul&amp;gt;, Buzz, Fizz, Number&amp;lt;97ul&amp;gt;, Number&amp;lt;98ul&amp;gt;, Fizz, Buzz&amp;gt;&lt;br /&gt;
*/&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Benefits and drawbacks of template metaprogramming==&lt;br /&gt;
Compile-time versus execution-time tradeoffs get visible if a great deal of template metaprogramming is used.&lt;br /&gt;
*  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}}.&lt;br /&gt;
* With respect to C++ prior to version &#039;&#039;C++11&#039;&#039;, the syntax and idioms of template metaprogramming were esoteric compared to conventional C++ programming, and template metaprograms could be very difficult to understand.&amp;lt;ref&amp;gt;{{cite web&lt;br /&gt;
| first1 = K.&lt;br /&gt;
| last1 = Czarnecki&lt;br /&gt;
| first2 = J.&lt;br /&gt;
| last2 = O&#039;Donnell&lt;br /&gt;
| first3 = J.&lt;br /&gt;
| last3 = Striegnitz&lt;br /&gt;
| first4 = Walid Mohamed&lt;br /&gt;
| last4 = Taha&lt;br /&gt;
| title = DSL implementation in metaocaml, template haskell, and C++&lt;br /&gt;
| publisher = University of Waterloo, University of Glasgow, Research Centre Julich, Rice University&lt;br /&gt;
| year = 2004&lt;br /&gt;
| url = http://camlunity.ru/swap/Library/Computer%20Science/Metaprogramming/Domain-Specific%20Languages/DSL%20Implementation%20in%20MetaOCaml,%20Template%20Haskell%20and%20C++.pdf&lt;br /&gt;
|quote=&#039;&#039;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.&#039;&#039;&lt;br /&gt;
| ref = Czarnecki, O’Donnell, Striegnitz, Taha - DSL implementation in metaocaml, template haskell, and C++&lt;br /&gt;
}}&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;{{cite web&lt;br /&gt;
| first1 = Tim&lt;br /&gt;
| last1 = Sheard&lt;br /&gt;
| authorlink2 = Simon Peyton Jones&lt;br /&gt;
| first2 = Simon Peyton&lt;br /&gt;
| last2 = Jones&lt;br /&gt;
| title = Template Meta-programming for Haskell&lt;br /&gt;
| publisher = ACM 1-58113-415-0/01/0009&lt;br /&gt;
| year = 2002&lt;br /&gt;
| url = http://research.microsoft.com/en-us/um/people/simonpj/papers/meta-haskell/meta-haskell.pdf&lt;br /&gt;
| quote = &#039;&#039;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&#039;&#039;&lt;br /&gt;
| ref = Sheard, S.P.Jones - Template Meta-programming for Haskell&lt;br /&gt;
}}&amp;lt;/ref&amp;gt; But from C++11 onward the syntax for value computation metaprogramming becomes more and more akin to &amp;quot;normal&amp;quot; C++, with less and less readability penalty.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Substitution failure is not an error]] (SFINAE)&lt;br /&gt;
* [[Metaprogramming]]&lt;br /&gt;
* [[Preprocessor]]&lt;br /&gt;
* [[Parametric polymorphism]]&lt;br /&gt;
* [[Expression templates]]&lt;br /&gt;
* [[Variadic template]]&lt;br /&gt;
* [[Compile-time function execution]]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{Reflist}}&lt;br /&gt;
* {{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 }}&lt;br /&gt;
* {{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 }}&lt;br /&gt;
* {{cite book | authorlink1 = David Abrahams (computer programmer) | first1 = David | last1 = 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 }}&lt;br /&gt;
* {{cite book | authorlink1 = David Vandevoorde | first1 = David | last1 = Vandevoorde | 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 }}&lt;br /&gt;
* {{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 | publisher = Cambridge University Press }}&lt;br /&gt;
&lt;br /&gt;
==External links==&lt;br /&gt;
* {{cite web | url = http://www.boost.org/libs/mpl/doc/ | title = The Boost Metaprogramming Library (Boost MPL) }}&lt;br /&gt;
* {{cite web | url = http://www.boost.org/libs/spirit/ | title = The Spirit Library }} (built using template-metaprogramming)&lt;br /&gt;
* {{cite web | url = http://www.boost.org/doc/libs/1_57_0/doc/html/lambda.html | title = The Boost Lambda library }} (use STL algorithms easily)&lt;br /&gt;
* {{cite journal | url = http://ubiety.uwaterloo.ca/~tveldhui/papers/Template-Metaprograms/meta-art.html | archiveurl = https://web.archive.org/web/20090304154029/http://ubiety.uwaterloo.ca/~tveldhui/papers/Template-Metaprograms/meta-art.html | archivedate = 2009-03-04 | title = Using C++ template metaprograms | journal = C++ Report | volume = 7 | issue = 4 | date = May 1995 | pages = 36–43 | first = Todd | last = Veldhuizen }}&lt;br /&gt;
* {{cite web | url = https://wiki.haskell.org/Template_Haskell | title = Template Haskell }} (type-safe metaprogramming in Haskell)&lt;br /&gt;
* {{cite web | authorlink = Walter Bright | first = Walter | last = Bright | url = http://www.digitalmars.com/d/templates-revisited.html | title = Templates Revisited }} (template metaprogramming in the [[D programming language]])&lt;br /&gt;
* {{cite web | url = http://staff.ustc.edu.cn/~xyfeng/teaching/FOPL/lectureNotes/MetaprogrammingCpp.pdf | title = Metaprogramming in C++ | authorlink = Johannes Koskinen | first = Johannes | last = Koskinen | access-date = 2014-06-20 | archive-date = 2014-08-28 | archive-url = https://web.archive.org/web/20140828190250/http://staff.ustc.edu.cn/~xyfeng/teaching/FOPL/lectureNotes/MetaprogrammingCpp.pdf | url-status = dead }}&lt;br /&gt;
* {{cite web | url = http://lcgapp.cern.ch/project/architecture/ReflectionPaper.pdf | title = Reflection support by means of template metaprogramming | first1 = Giuseppe | last1 = Attardi | first2 = Antonio | last2 = Cisternino | access-date = 2008-10-24 | archive-date = 2016-03-03 | archive-url = https://web.archive.org/web/20160303183212/http://lcgapp.cern.ch/project/architecture/ReflectionPaper.pdf | url-status = dead }}&lt;br /&gt;
* {{cite CiteSeerX | citeseerx = 10.1.1.14.5881 | title = Static data structures | first1 = Michael C. | last1 = Burton | first2 = William G. | last2 = Griswold | first3 = Andrew D. | last3 = McCulloch | first4 = Gary A. | last4 = Huber | year = 2002 }}&lt;br /&gt;
* {{cite web | url = http://www.codeproject.com/Articles/19989/Template-Meta-Programming-and-Number-Theory | title = Template Meta Programming and Number Theory | first = Zeeshan | last = Amjad | date = 13 August 2007 }}&lt;br /&gt;
* {{cite web | url = http://www.codeproject.com/Articles/20180/Template-Meta-Programming-and-Number-Theory-Part | title = Template Meta Programming and Number Theory: Part 2 | first = Zeeshan | last = Amjad | date = 24 August 2007 }}&lt;br /&gt;
* {{cite web | url = http://www.intelib.org/intro.html | title = A library for LISP-style programming in C++ }}&lt;br /&gt;
&lt;br /&gt;
{{Programming paradigms navbox}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Metaprogramming]]&lt;br /&gt;
[[Category:C++]]&lt;br /&gt;
[[Category:Articles with example C++ code]]&lt;/div&gt;</summary>
		<author><name>2605:8D80:13E0:E0D0:2DE3:913E:61B7:51CC</name></author>
	</entry>
</feed>