This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: interface/implementation: export keyword?


> 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]