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: Nathan Myers <ncm at cygnus dot com>
- Subject: Re: explicit specialization in non-namespace scope
- From: Alexandre Oliva <oliva at dcc dot unicamp dot br>
- Date: 22 Sep 1998 07:39:57 +-300
- Cc: egcs at cygnus dot com
- References: <Pine.GSO.3.96.980921144445.7109I-100000.cygnus.egcs@lystra.lysator.liu.se> <3606BFC2.D2A647E1@cygnus.com>
Nathan Myers <ncm@cygnus.com> writes:
>> > 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. */
> It's still not clear that the above text applies to the case mentioned.
> "In the namespace of which the enclosing class is a member" is satisified
> both outside and inside the class. When it means to say "not in a class
> or in a block", it says "at namespace scope" or sometimes "in namespace
> scope"
> Anyhow, all is not lost. You can specialize this member anyway,
> even in egcs with bug added, just not as cleanly as you wanted:
> struct A {
> template <int I> inline int factorial();
> };
> template <> inline int A::f<0>() { return 1; }
> template <int I> inline void A::f<I>() { return f<I-1>() * I; }
Unfortunately, this won't work if A is a template class, because,
AFAIK, in order to specialize A<...>::factorial<I>, A<...> must be
fully specialized.
--
Alexandre Oliva
mailto:oliva@dcc.unicamp.br mailto:aoliva@acm.org
http://www.dcc.unicamp.br/~oliva
Universidade Estadual de Campinas, SP, Brasil