M
Maxim Yegorushkin
The following code perfectly compilable with Comeau online and gcc 3.2 produces quite an obscure error message when compiled with VC7.1.
namespace N {
struct A
{
template<class F>
void fun(F f);
};
}
template<class F>
void N::A::fun(F f) // (1)
{
f(*this);
}
void g(N::A&);
template<class T> // (2)
struct B : N::A
{
B()
{
this->fun(&::g); // error C2660: 'N::fun' : function does not take 2 arguments
}
};
int main()
{
B<void> b;
}
Please note that the error message mention N::fun function, but there is no one, rather there is N::A::fun.
I've found that I can work around the bug by placing (1) function definition inside namespace N or making B class (2) non template.
Could some competent person comment the situation?
namespace N {
struct A
{
template<class F>
void fun(F f);
};
}
template<class F>
void N::A::fun(F f) // (1)
{
f(*this);
}
void g(N::A&);
template<class T> // (2)
struct B : N::A
{
B()
{
this->fun(&::g); // error C2660: 'N::fun' : function does not take 2 arguments
}
};
int main()
{
B<void> b;
}
Please note that the error message mention N::fun function, but there is no one, rather there is N::A::fun.
I've found that I can work around the bug by placing (1) function definition inside namespace N or making B class (2) non template.
Could some competent person comment the situation?