title: c++ generic pointer to (member?) function
body: <p>I can't seem to declare a generic pointer to function.</p>
  
  <p>Having these 2 functions to be called:</p>
  
  <pre><code>void myfunc1(std::string str)
  {
      std::cout &lt;&lt; str &lt;&lt; std::endl;
  }
  struct X
  {
          void f(std::string str){ std::cout&lt;&lt; str &lt;&lt; std::endl;}
  };
  </code></pre>
  
  <p>and these two function callers:</p>
  
  <pre><code>typedef void (*userhandler_t) (std::string);
  struct example
  {   
      userhandler_t userhandler_;
  
      example(userhandler_t userhandler): userhandler_(userhandler){}
  
      void call(std::string str)
      {   
          userhandler_(str);
      }
  };
  template&lt;typename func_t&gt;
  void justfunc(func_t func)
  {
      func("hello, works!");
  }
  </code></pre>
  
  <p>when I try to use them with boost::bind to call the member function they give me compile errors.</p>
  
  <p>this works:</p>
  
  <pre><code>example e1(&amp;myfunc1);
  e1.call("hello, world!");
  justfunc(&amp;myfunc1);
  </code></pre>
  
  <p>this doesn't:</p>
  
  <pre><code>X x;
  example e2(boost::bind(&amp;X::f, &amp;x, _1));
  e2.call("hello, world2!");
  justfunc(boost::bind(&amp;X::f, &amp;x, _1));
  </code></pre>
  
  <p>How is this supposed to be done?</p>