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

Reply via email to