Kagamin wrote:
BCS Wrote:
smaller object code? OTOH a good implementation will noice when I can fold
together several template expansions
That's the difference. You can't fold templates because they're binary
incompatible as opposite to generics.
They're not always binary-incompatible. For instance, if a template only works
with pointers or references (this includes object references) to parameter types
it might well contain the exact same machine code for some of the instantiations.
A compiler backend or linker could recognize these cases and use a single
instantiation's machine code for them.
(Essentially, these are pretty much the same cases where generics would have
been sufficient)