This is the mail archive of the
mailing list for the libstdc++ project.
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
My guess is that explicit instantiations have the rule because
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,