I'm trying to figure out the root cause of a type conversion issue with pointers to member functions in C++ (VS2012).
I've narrowed it down to the difference in the typeid
of a pointer to a template member function and a non-template member function. Consider the code:
#include <typeinfo>
#include <iostream>
class foo
{
public:
template<int k>
void func1() {}
void func2() {}
};
typedef void (foo::*foofunc)();
int main()
{
//this gives "int"
std::cout<<typeid(&foo::func1<3>).name()<<std::endl;
//this gives "void (__thiscall *)(void)"
std::cout<<typeid(&foo::func2).name()<<std::endl;
return 0;
}
func2
has the expected value. Why does a pointer to func1
have type int
when both are member functions of the same class?
NOTE: This happens only on Windows.