This is precisely the trouble with templates: you need to learn yet another language for what can be templated & what cannot. Adding in the C preprocessor, you now need to know 3 completely different languages in order to write these C++ programs. While there is a distinction between Lisp macros and Lisp functions, at least you can construct Lisp macros with standard Lisp functions. A huge fraction of templating could be eliminated with proper function closures and proper "inlining". For example, most modern Lisps are capable of inlining mapping functions which apply functions given as arguments to sequences of various kinds. The lambda calculus tells us how to do these things correctly, if we will only listen. At 10:24 PM 4/20/2014, Joerg Arndt wrote:
template <typename Type> void sort_whatever(Type *x, int n) { ... }
will sort any Type if all operations in the routine are defined for Type.
And templates are not functions, the corresponding functions are generated at compile time.