title: How do I get the address of a c-style function stored in an std::function?
body: <p>I would like to print, for debugging purposes, the address of the function pointer stored in my std::function. I can guarantee that the std::function is going to point to a c-style function or a lambda. Is there any way to do this?</p>
  
  <p>Otherwise I am going to have to store the function pointer in memory when it is added and modify all the lambdas.</p>
  
  <p>I have attempted to use the answer here <a href="https://stackoverflow.com/a/18422878/274249">https://stackoverflow.com/a/18422878/274249</a> but it doesn’t seem to work.</p>
  
  <p>Some example code:</p>
  
  <pre><code>std::function&lt;void()&gt; func = commands.front();
  void * fp = get_fn_ptr&lt;0&gt;(func);
  void * bb = &amp;glBindBuffer;
  printf("bb is %x\n", bb); // Outputs 5503dfe0
  printf("fp is %x\n", fp); // Should be the same as above, but outputs 4f9680
  </code></pre>