How do I print the address of a method pointer in C++?
<p>For example:</p>

<pre><code>struct A { void m() { } };

void stream_print() {
  void(A::*p)(void) = &amp;A::m;
  std::cerr &lt;&lt; p &lt;&lt; std::endl;
}

void printf_print() {
  void(A::*p)(void) = &amp;A::m;
  fprintf(stderr, "%p", p);
}
</code></pre>

<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*.</p>

<p>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.</p>

<p>I am using g++ 4.4.3 with C++0x enabled.</p>

<p>Let me know if you have any doubts.</p>
