interface/implementation: export keyword?

Martin von Loewis martin@mira.isdn.cs.tu-berlin.de
Sat Oct 31 16:39:00 GMT 1998


> Surely there must be an elegant way of doing this already, or does
> nobody else use templates and require them to be space-efficient?

egcs currently uses two techniques by default to safe space in
template instantiation:

a) In implicit instantiations, it emits code only if it is used in the
   same translation unit. For example, if you instantiate a list<Foo>&
   in a parameter, and then use only empty() on that parameter, it only
   emits code for .empty() (this is the theory, some other things get
   instantiated which would not need to)

b) If the same function/method is emitted multiple times in different
   object files, the linker will remove the duplicates (if it's a GNU
   linker)

This together more or less makes all other techniques
(-fno-implicit-templates, #pragma, -frepo) obsolete. 'export' will
survive (once it is born :-), as it is required by the standard.

Regards,
Martin



More information about the Gcc mailing list