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: C++ PATCH: PR 13140


Benjamin Kosnik wrote:

> However, when we were presenting in Kona about namespace association,
> nobody (Gaby, Bjarne, Daveed) could remember why this particular
> behavior is required in the first place.
> 
> Any thoughts?

I talking about it with John Spicer before posting this patch (he was
the one who pointed me at DR 275), but I didn't ask about the thinking
behind it.

My guess is that explicit instantiations have the rule because
specializations do.

I do think it makes sense that specializations have to be declared in
the namespace where the template is located; that's an encapsulation
idea.  I think the rationale for specialization in an enclosing
namespace, rather than just the one in which it was declared, but not in
some unrelated namespace, is that it means that a library can specialize
its own templates, and, if properly declared, so can a program using
that library, but some other third-party library in its own namespace
can't mess with the templates from the first library.  That's presumably
the reason for the rules around where you can define static data members
and member functions (regardless of whether or not they are in templates).

My two cents,

-- 
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
(916) 791-8304


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