[Gllug] C++ Templates, Opinions?

Nix nix at esperi.org.uk
Fri Dec 17 16:55:38 UTC 2004


On Thu, 16 Dec 2004, Ian Norton-Badrul suggested tentatively:
> I was just wondering what people though about using function/class
> templates in C++, To me it looks clever but like it could drastically
> reduce the readability of C++ code (ie find a func call, go looking for
> it in code, cant find it directly etc)

You have *that* problem with overloading, polymorphism, and namespaces,
in any case. Templates don't make it any worse, and their power is such
that I'd not discard them, and I feel constrained whenever I use a
language that doesn't have them (or a related feature like ML's pattern
matching --- from which the C++ template model was derived --- or Lisp's
macros).


I personally think templates are by far the best feature of C++. If you
want to be awed, read Alexandrescu's mistitled _Modern C++ Design_:
<http://www.accu.org/cgi-bin/accu/rvout.cgi?from=0au_a&file=m002281a>.

As Francis says in his review,

`By the time you have finished reading and thinking about this material
 you will wonder why you ever doubted the power of C++ templates.'

He's right.

-- 
`The sword we forged has turned upon us
 Only now, at the end of all things do we see
 The lamp-bearer dies; only the lamp burns on.'
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list