Questions Concepts
GitHub icon


Templates - language feature

< >
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);
Example from Nim:
# template debug*(args: varargs[string, `$`]) = if logLevel <= Level.debug: const module = instantiationInfo().filename[0 .. ^5] echo "[$# $#][$#]: $#" % [getDateStr(), getClockStr(), module, join args]

Languages with Templates include C++, D, Nim, XL, Real-Time Concurrent C

Languages without Templates include C, Objective-C, Speedie, Tick C

This question asks: Does the language support templates?

Read more about Templates on the web: 1.

HTML of this page generated by Features.ts

View source

- Build the next great programming language Search Add Language Features Creators Resources About Blog Acknowledgements Queries Stats Sponsor Traffic Traffic Today Day 305 Logout