I am working on some system files like C ++, and I am having the problem of removing a constant from a member function for use with function classes. What really bothers here is that it works fine with g ++, but MSVC10 does not handle partial specialization correctly, and I donβt know if one of these compilers really has an error.
The question is, what is the correct way to remove the constant determinant from a member function so that I can get the signature of the function type?
Take the following code example:
#include <iostream> template<typename T> struct RemovePointer { typedef T Type; }; template<typename T> struct RemovePointer<T*> { typedef T Type; }; template<typename R,typename T> struct RemovePointer<R (T::*)> { typedef R Type; }; class A { public: static int StaticMember() { return 0; } int Member() { return 0; } int ConstMember() const { return 0; } }; template<typename T> void PrintType(T arg) { std::cout << typeid(typename RemovePointer<T>::Type).name() << std::endl; } int main() { PrintType(&A::StaticMember); PrintType(&A::Member); PrintType(&A::ConstMember); // WTF? }
All three of these PrintType statements must print the same thing. MSVC10 prints the following:
int __cdecl(void) int __cdecl(void) int (__cdecl A::*)(void)const __ptr64
g ++ prints this (which is the expected result):
FivE FivE FivE
source share