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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [v3] speedup numpunct cache a bit


On Sat, Jun 28, 2003 at 12:17:18AM -0400, Jerry Quinn wrote:
> Nathan Myers writes:
>  > On Fri, Jun 27, 2003 at 10:38:02PM -0400, Jerry Quinn wrote:
>  > > This moves the code for __use_cache<numpunct> to locale_facets.tcc.
>  > 
>  > Making it inline is a wondrous thing, but all inlines must go in 
>  > ".h" files.  Everything in a .tcc file is supposed to be able to 
>  > be declared "export" and not need to be seen at instantiation time, 
>  > meaning (mainly) no public class declarations and no inlines.
> 
> <novice> How does export work? </novice>

It's meant to extend the benefits separate compilation to template
instantiations.  People have said that export was a failed 
experiment, or a deeply sinful instance of invention by committee, 
but Daveed Vandevoorde of EDG reports that, now that they have 
implemented it, it appears actually to be useful as intended, and 
the nightmare misuses they had feared seem not to be attractive to 
real developers.

In practice, the template definitions (more or less in source form)
get put in the object library (along with the header definitions 
they depend on) and the templates get instantiated and compiled at 
what we are used to thinking of as link time.  The purpose is to 
minimize the amount of stuff that has to be #included, and to allow 
changes to the .tcc files, and the library they appear in, without 
recompiling .o files that don't need to know about implementations.

> __use_cache is only being used within the .tcc file.  Does it still
> have to be in the .h?  Why doesn't this apply to std::use_facet and
> std::has_facet - or should it?

My mistake.  If it's used only in the .tcc file, then it only need
be declared/defined there, inline or no.  use_facet<> and has_facet<> 
should not be in the .tcc file.  If they are (I haven't looked), 
that's something to fix.

>  > This might not have been explained anywhere that you would have 
>  > been likely to encounter.
> 
> No problem.  Is there a place in the docs or guidelines that this
> tidbit should go?

It's mentioned in /docs/html/17_intro/HEADER_POLICY, but not why.  
I don't know where else it ought to go.  

Nathan Myers
ncm-nospam@cantrip.org


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