extern template in V3 (was: Re: GCC viciously beaten...)

Paolo Carlini pcarlini@suse.de
Mon Mar 15 23:38:00 GMT 2004


[I'm moving the discussion to libstdc++, seems more appropriate]

Gabriel Dos Reis wrote:

>There are two points of history here:
>  (1) in the dark ages, "extern template" was supposed to provide a
>      form of separate compilation of templates -- in fact, 
>      that syntax was rumored along with "export"; there were long,
>      "heated" debates, and in final, "export" syntax won.  Note too,
>      that "export" or "extern template" can in only after some "radical"
>      positions were operated (some implementors adopted to replace
>      the kind of separate compilation provided by CFront with the
>      inclusion model championed in the Borland implementation.  I was
>      told recently that it would be an MS extension actually).
>  
>
I see, thanks.

>  (2) In the current proposal for "extern template", it is just a way
>      to tell the compiler not to instantiate right now from an
>      arbitraty template definition that would be around.  It is
>      essentially a mean to forward declare an explicit instantiation.
>
>We use "extern templates" only as code-size optimization.  It could be
>removed without damage.
>  
>
In the meanwhile I'm re-reading §10.4 of Vandevoorde & Josuttis about 
related
issues and wondering whether the current linkers (the GNU one, in 
particular)
are able to automatically deal with this issue, code-size optimization, 
that is...

Wasting compile time in redundant instantiations may be also an important
concern, right?

Another, more practical, curiosity I have is the following: now I'm also 
reading
the manual about extern template and it talks about "to allow forward 
declaration
of explicit instantiations", however, I'm not at all sure that *all* the 
instantiations
suppressed via extern have a corresponding *explicit* instantiation 
somewhere!

Paolo.



More information about the Libstdc++ mailing list