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: egcs at cygnus dot com
- Subject: Re: explicit specialization in non-namespace scope
- From: Nathan Myers <ncm at nospam dot cantrip dot org>
- Date: Fri, 18 Sep 1998 16:53:43 -0700
- Newsgroups: cygnus.egcs
- Organization: http://www.cantrip.org/
- References: <Pine.GSO.3.96.980917184923.7109A-100000@lystra.lysator.liu.se>, <orvhmmk52m.fsf.cygnus.egcs@tiete.dcc.unicamp.br>
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