J
Jaap
Hi,
I'm trying to get a member template of a template class defined
out-of-line. I'm failing miserably, though. Is this even possible ?
template <typename T>
struct foo
{
// Declare member template
template <typename U>
void bar(U);
};
// Define member template
template <typename T, typename U>
void foo<T>::bar(U)
{
}
VC.NET gives me:
ref.cpp(13) : error C2244: 'bar' : unable to match function definition
to an existing declaration
definition
'void foo<T>::bar(T2)'
existing declarations
'void foo<T>::bar(U)'
GCC says:
Line 10: error: prototype for `void foo::bar(U)' does
not match any in class `foo'
Line 5: error: candidate is: template
template void foo::bar(U)
Line 10: error: template definition of non-template `
void foo::bar(U)'
Any insights are appreciated,
Jaap
I'm trying to get a member template of a template class defined
out-of-line. I'm failing miserably, though. Is this even possible ?
template <typename T>
struct foo
{
// Declare member template
template <typename U>
void bar(U);
};
// Define member template
template <typename T, typename U>
void foo<T>::bar(U)
{
}
VC.NET gives me:
ref.cpp(13) : error C2244: 'bar' : unable to match function definition
to an existing declaration
definition
'void foo<T>::bar(T2)'
existing declarations
'void foo<T>::bar(U)'
GCC says:
Line 10: error: prototype for `void foo::bar(U)' does
not match any in class `foo'
Line 5: error: candidate is: template
template void foo::bar(U)
Line 10: error: template definition of non-template `
void foo::bar(U)'
Any insights are appreciated,
Jaap