title: How to initialize `std::function` with a member-function?
body: <p>I am trying to learn <code>std::function</code> and here's my code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;functional&gt;
  
  struct Foo {
      void print_add(int i){ 
        std::cout &lt;&lt; i &lt;&lt; '\n'; 
      }
  };
  
  typedef std::function&lt;void(int)&gt; fp;
  
  void test(fp my_func)
  {
    my_func(5);
  }
  
  int main(){
      Foo foo;
      test(foo.print_add);
      return 0;
  }
  </code></pre>
  
  <p><strong>Compiler Error:</strong></p>
  
  <pre><code> error: cannot convert 'Foo::print_add' from type 'void (Foo::)(int)' to type 'fp {aka std::function&lt;void(int)&gt;}'
       test(foo.print_add);
  </code></pre>
  
  <p>How can I make this work, i.e how can I pass a member function as a parameter?</p>