Templates is an actively used design pattern created in 1995. Template metaprogramming (TMP) is a metaprogramming technique in which 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 include compile-time constants, data structures, and complete functions. The use of templates can be thought of as compile-time execution. Read more on Wikipedia...

24Years Old
  • Templates ranks in the top 25% of entities I track
  • the Templates wikipedia page
  • Templates first appeared in 1995
  • Have a question about Templates not answered here? Email me and let me know how I can help.

Languages with Templates include cpp, d, xl-programming-language

Example from cpp:

template <int length>
Vector<length>& Vector<length>::operator+=(const Vector<length>& rhs)
    for (int i = 0; i < length; ++i)
        value[i] += rhs.value[i];
    return *this;

Example from d:

template TCopy(T)
    void copy(out T to, T from)
        to = from;
int i;
TCopy!(int).copy(i, 3);

Last updated June 22nd, 2020

Edit Templates on GitHub