[C++ templates]
> Definitely bloat generating. Each time you use a template with a different
> type, the compiler has to effectively make a new class, complete with all
> code, for that type. That's a pretty good definition of bloat IMHO.
If they are bloat generating, then they are not being used correctly.
C++ templates, correctly used, are, eg, a type-enforcement system for
untyped containers; that is, you have a class that implements, say, a
list, in terms of void pointers; then you implement an almost empty
template on top of that that *privately* inherits from the untyped list,
and reimplements its accessors in terms of typesafe casts to the untyped
list accessors.
This works, and has zero bloat; in fact it is *more* compact than the
analogous magic-number-based implementation in C, relying instead upon
the RTTI structures already generated by the compiler.
So please stop saying templates are bloated. They *are* easy to produce
bloated stuff in, and could probably be faulted for that; but they are
*not* intrinsically bloat creators. It is perfectly possible (and easy)
to produce non-bloating, typesafe stuff with templates.
(Also, look at Blitz++. Then try to reimplement *that* in C, or in
templateless C++. Of course, strictly speaking what Blitz++ does is
an abuse of the template system, and the code is quite ugly...)
-- `Ha! I wouldn't trust NT to level a desk!' --- Paul Anderson in freebsd-newbies- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/