title: Pass and call a member function (boost::bind / boost::function?)
body: <p>I have a probably embarassingly simple problem: pass and call a member function in a class. I know I want to use BOOST bind (and or function), but I haven't really grasped the concept to it yet.</p>
  
  <p>The following code compiles and executes with problem. But when I want to change the "f3" function to a non-static class function, then the fun begins:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;inttypes.h&gt; 
  #include &lt;boost/bind.hpp&gt;
  #include &lt;boost/function.hpp&gt;
  
  class Test
  {
  public:
    void f1();
  private:
    void f2(void (*callfunc)(uint32_t));
    static void f3(uint32_t x);
  };
  
  void Test::f1(){
    f2(f3);
  }
  
  void Test::f2(void (*callfunc)(uint32_t)){
    (*callfunc)(42);
  }
  
  void Test::f3(uint32_t x){
    std::cout &lt;&lt; "x: " &lt;&lt; x &lt;&lt; std::endl;
  }
  
  int main(int argc, char ** argv)
  {
    Test ct;
    ct.f1();
    return 0;
  }
  </code></pre>
  
  <p>Now, after changing</p>
  
  <pre><code>static void f3(uint32_t x);
  </code></pre>
  
  <p>to</p>
  
  <pre><code>void f3(uint32_t x);
  </code></pre>
  
  <p>the compiler isn't happy and tells me "error: no matching function for call to 'Test::f2()'"</p>
  
  <p>Having read through a number of SO posts regarding boost::bind and boost::function, I think I need to change the definition of f2() and how f1() calls f2() giving f3() as target to call, but apart from that ... about every combination of boost::bind and boost function I tried miserably fails to compile.</p>
  
  <p>How do I need to write this? As a bonus question: are there any simple introductory reads on boost::bind and boost::function? The BOOST docs did not really help me there.</p>
  
  <p>B.</p>