This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: (C++) bug in explicit template specialization


> 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 name­space 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]