explicit specialization in non-namespace scope
Nathan Myers
ncm@nospam.cantrip.org
Fri Sep 18 22:10:00 GMT 1998
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
More information about the Gcc
mailing list