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


Alexandre Oliva wrote:
> 
> Oskar Enoksson <osken393@student.liu.se> writes:
> 
> > The following code compiles with egcs 1.1 but not with egcs-19980914,
> > Which is wrong?
> > struct X { 
> >   template<int M> int Faculty()    { return M*Faculty<M-1>(); }
> >   template<>      int Faculty<0>() { return 1; }
> > };
> 
> egcs 1.1.  According to the Standard, template specializations can
> only be declared in namespace scope.

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

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

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

Nathan Myers
ncm@cantrip.org


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