For example:
struct A { void m() { } }; void stream_print() { void(A::*p)(void) = &A::m; std::cerr << p << std::endl; } void printf_print() { void(A::*p)(void) = &A::m; fprintf(stderr, "%p", p); } The stream_print() function always prints "1", which is obviously not what I want. The printf_print does not compile because p cannot be casted to void*.
What I need is a unique identifier for a method pointer that I can store in a container. I know this sounds like a bad idea, but I am developing a small toy for unit testing that can benefit from it. I am not worried about overloads of the method, I know how to get the pointer to a specific overload.
I am using g++ 4.4.3 with C++0x enabled.
Let me know if you have any doubts.