This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: (C++) bug in explicit template specialization
- To: khan at xraylith dot wisc dot EDU
- Subject: Re: (C++) bug in explicit template specialization
- From: "Martin v. Loewis" <martin at mira dot isdn dot cs dot tu-berlin dot de>
- Date: Sat, 10 Jul 1999 11:41:16 +0200
- CC: egcs-bugs at egcs dot cygnus dot com
- References: <199907100204.VAA04243@mercury.xraylith.wisc.edu>
> According to 14.7.3 [temp.expl.spec], the following code is legal.
No. [temp.expl.spec]/2 says
>> 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.
You are not declaring a member template, so the specialization must be
in the namespace where the template is a member, i.e. N.
It also says
>> If the declaration is not a definition, the specialization may be
>> defined later in the namespace in which the explicit
>> specialization was declared, or in a namespace that encloses the
>> one in which the explicit specialization was declared.
Unfortunately, it is not clear whether this holds for explicit
>> specialization of a member function, member class or static data
>> member of a class template
only (which the previous sentences talks about), but let's assume it
holds for all specializations. Then, in order to define the template
in a namespace that encloses the one where the template was declared,
you also have to declare the template in that namespace.
Therefore, your example is ill-formed.
Regards,
Martin