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


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

Re: explicit specialization in non-namespace scope


>>>>> "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


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