Languages Features Calendar CSV Lists Blog About Sponsor Add Language
GitHub icon



Templates are a feature.

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...

Languages with Templates include C++, D, XL

Example from C++:
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);
symbol-table-feature.html 路 templates-feature.html 路 multiple-dispatch-feature.html

View source

PLDB - Build the next great programming language 路 v2022 Day 33 Docs Build Acknowledgements Traffic Today Traffic Trends Mirrors GitHub