This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/28130] New: template function(from a class inside a namespace) specialization outside the namespation
- From: "zvonsully at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 21 Jun 2006 22:47:03 -0000
- Subject: [Bug c++/28130] New: template function(from a class inside a namespace) specialization outside the namespation
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
I define a namespace with a template class with a function:
<code>
namespace NS{//a namespace
template<class T>
class C//a template class inside a namespace
{
int f();//a member of C
};
}//NS
//here is the specialization
template<>
int NS:: C<int>::f(){return 0;}// !! I placed NS::
</code>
compiler output:
$g++ x.cpp
x.cpp:14: error: specialization of 'int NS::C<T>::f() [with T = int]' in
different namespace
x.cpp:14: error: from definition of 'int NS::C<T>::f() [with T = int]'
$
I think the compiler should not gice an error.
Workaround until fix: specialization in the namespace
<code>
namespace NS{
template<>
int C<int>::f(){return 0;}
}
</code>
--
Summary: template function(from a class inside a namespace)
specialization outside the namespation
Product: gcc
Version: 4.1.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: zvonsully at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28130