Why Templates?

Tom Tom_member at pathlink.com
Sat Mar 4 18:45:59 PST 2006


In article <op.s5wxef016b8z09 at ginger.vic.bigpond.net.au>, Derek Parnell says...
>
>I'm sure its because I'm not from a C++ background, but I just don't get  
>templates. What is the problem that Templates solve?

I'm passing away... my pressure!!! :P

> From my limited experience they just seem to be a shorthand for a way of  
>avoiding coding identical algorithms that only vary in the datatypes that  
>are passed to them. Is that it or am I missing some fundamental elements?

Isn't this issue enough to justify templates?

I have some interesting experience with C++, I'm not an expert even though I've
coded a lot in it and I've used "nearly all" (that means excluding the infamous
ones such as those modern cast operators :), etc.). I have no doubts, I can say
that one of the best features I've ever seen working in a language is the C++
templates.

I've coded really generic functions/containers with a great success in C++ and
used them with a variety of stuff. Always worked nice!

>And is that why people are clamoring for implicit template instantation -  
>to further reduce the amount of typing to do (and remembering to  
>instantiate the only the required renditions of the algorithm).

Tom;



More information about the Digitalmars-d mailing list