C++ automatic template instantiation?

Martin v. Loewis martin@loewis.home.cs.tu-berlin.de
Wed Apr 19 15:22:00 GMT 2000


> Isn't that going to make your code n times larger because it will
> instantiate all the templates in all the object files?

It instantiates only those that are needed, not all of those that an
explicit instantiation would instantiate.

Also, if you have a smart linker (such as GNU ld), the linker will
remove the duplicates when linking, so only one copy makes it into the
executable.

Regards,
Martin



More information about the Gcc mailing list