While what you've said is correct, there's another factor involved. People who know and love templates tend to avoid old C-style generic programming, such as used in the qsort() routine commonly found on UNIX systems. Such old code worked on arbitrary arguments by taking arguments from the caller specifying void*s to values, sizes in bytes if necessary, and function pointers to operate meaningfully on the memory content. It was not type safe, but it did mean the one block of compiled code could be reused on arbitrary types. Compared to this, instantiating templates for myriad types does generate a lot of executable code. On the other hand, that code might run faster as inlining and other optimisations are possible. Similarly, doing things like "template " where A and B might be the sizeof a couple strings being passed to the constructor can very quickly lead to hundreds of copies of the template as A and B vary. Often, any optimisations that allows aren't worth the bloat. Sometimes, clever programmers will actually use a lightweight template to provide type safety, for example: template class X { typedef map Map; } where E is expected to be an enum, but it's not too painful to convert the values to ints for private Maps.... Cheers, Tony
Recent comments
9 hours 24 min ago
14 hours 28 min ago
14 hours 57 min ago
1 day 7 hours ago
1 day 14 hours ago
1 week 6 days ago
3 weeks 8 hours ago
3 weeks 1 day ago
3 weeks 3 days ago
3 weeks 4 days ago