title: null pointer when getting function pointer using boost::function::target
body: <p>After reading <a href="https://stackoverflow.com/questions/282372/demote-boostfunction-to-a-plain-function-pointer" title="this answer">this answer</a> I thought I had a solution.  At least the answer there is what I would like to do but I'm having a problem with the implementation.</p>
  
  <p>here is an outline of what I am trying to do</p>
  
  <pre><code>typedef map&lt;string, double*&gt; myMap;
  typedef int (*ftwpt)(const char*, const struct stat*, int);
  typedef boost::function&lt;int(const char*, const struct stat*, int)&gt; MyFTWFunction;
  
  int myFunction(const char*, const struct stat*, int, myMap*);
  
  int main()
  {
  myMap m_map;
  char tmpdir[] = "/tmp/mytmp";
  
  MyFTWFunction f = boost::bind(myFunction,_1,_2,_3, &amp;m_map);
  
  ftwpt* fpt = f.target&lt;ftwpt&gt;();
  if (fpt)
      status = ftw(tmpdir, *fpt, 50);
  else
  {
      cout &lt;&lt; "Boost could not perform runtime conversion on function pointer" &lt;&lt; endl;
      return (EXIT_FAILURE);
  }
  }
  </code></pre>
  
  <p>the program compiles with no errors or warnings but I am getting a null pointer (fpt) returned from f.target(); at runtime. From references linked on the above stackoverflow question it seems a null pointer is returned if boost is unable to perform the runtime conversion.  But I have no idea why Boost might not be able to perform the runtime conversion.  Any ideas?</p>