explicit specialization in non-namespace scope
Mark Mitchell
mark@markmitchell.com
Sat Sep 19 12:03:00 GMT 1998
>>>>> "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
More information about the Gcc
mailing list