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@nospam.cantrip.org> writes:

    Nathan> I believe this is incorrect.  I find no such restriction.
    Nathan> In addition, in 14.7.3 - Explicit specialization
    Nathan> [temp.expl.spec] we have:

    Nathan>    -17- A member or a member template may be nested within
    Nathan> many enclosing class templates. If the declaration of an
    Nathan> explicit specialization for such a member appears in
    Nathan> namespace scope, the member declaration shall be preceded
    Nathan> by a template<> for each enclosing class template that is
    Nathan> explicitly specialized.

    Nathan> It would not be necessary to say "if" above if that were
    Nathan> the only place it could appear.

Since I implemented this, I'd better defend myself. :-)

    [temp.expl.spec] 
     
     An explicit specialization shall be declared in the namespace of
     which the template is a member, or, for member templates, in the
     namespace of which the enclosing class or enclosing class
     template is a member.  An explicit specialization of a member
     function, member class or static data member of a class template
     shall be declared in the namespace of which the class template
     is a member.  */

Also, note that:

  template <class T>
  struct S { 
    template <class U>
    void f(U);
    template <> void f(int);
  };

is just like:

  template <class T>
  template <>
  void S<T>::f(int);

which is illegal, since S<T> isn't specialized.

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