This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: explicit specialization in non-namespace scope
- To: ncm at cygnus dot com
- Subject: Re: explicit specialization in non-namespace scope
- From: Mark Mitchell <mark at markmitchell dot com>
- Date: Tue, 22 Sep 1998 00:57:06 -0700
- CC: egcs at cygnus dot com
- References: <Pine.GSO.3.96.980921144445.7109I-100000.cygnus.egcs@lystra.lysator.liu.se> <3606BFC2.D2A647E1@cygnus.com>
- Reply-to: mark at markmitchell dot com
>>>>> "Nathan" == Nathan Myers <ncm@cygnus.com> writes:
>> Thanks for all answers!
Nathan> It's still not clear that the above text applies to the
Nathan> case mentioned. "In the namespace of which the enclosing
Nathan> class is a member" is satisified both outside and inside
Nathan> the class. When it means to say "not in a class or in a
Nathan> block", it says "at namespace scope" or sometimes "in
Nathan> namespace scope"; these are changed from "at global scope"
Nathan> which is what it said before we had namespaces. "In the
Nathan> namespace of" does not imply "only at namespace scope".
I can see the sense in your interpretation. (After all, besides
implementing the removal of this feature, I also implemented the
feature in the first place...)
But, do you think this is legal:
template <class T>
struct S {
template <class U>
void f(U);
template <>
void f(int);
};
even though:
template <class T>
struct S {
template <class U>
void f(U);
};
template <class T>
template <>
void S<T>::f(int);
is not? The standard says:
In an explicit specialization declaration for a member of a class tem-
plate or a member template that appears in namespace scope, the member
template and some of its enclosing class templates may remain unspe-
cialized, except that the declaration shall not explicitly specialize
a class member template if its enclosing class templates are not
explicitly specialized as well.
which doesn't say anything about specializations that are *not* in
namespace scope, which would therefore lead one to think this rule
does not apply. So specializations of member templates in template
classes are in fact required to be inline? Seems odd to me, although
I agree that the paragraph I quote adds credence to your point of view
about the legality of in-class specializations. Perhaps I had better
get that code out of CVS, and reenable it.
>> I can also report that Digital cxx rejects explicit member
>> template specializations.
Nathan> Digital is a poor choice of compilers to check
Nathan> conformance.
But EDG is a good choice, and it too complains on specializations in
class scope.
--
Mark Mitchell mark@markmitchell.com
Mark Mitchell Consulting http://www.markmitchell.com