title: Alternative to std::bind when passing member function
body: <p>I have some functions I'd like to benchmark. I would like be able to pass them into the benchmarking function. Previously I have passed a function pointer and reference to the object to the testing function like so</p>
  
  <pre><code>template&lt;typename T&gt;
  void (T::*test_fn)(int, int), T&amp; class_obj, )
  </code></pre>
  
  <p>At the moment I have this</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;functional&gt;
  using namespace std::placeholders;
  
  class aClass
  {
  public:
      void test(int a, int b)
      {
          std::cout &lt;&lt; "aClass fn : " &lt;&lt; a + b &lt;&lt; "\n";
      }
  
  };
  
  class bClass
  {
  public:
      void test(int a, int b)
      {
          std::cout &lt;&lt; "bClass fn : " &lt;&lt; a * b &lt;&lt; "\n";
      }
  
  };
  
  // Here I want to perform some tests on the member function
  // passed in
  class testing
  {   
  public:
      template&lt;typename T&gt;
      void test_me(T&amp;&amp; fn, int one, int two)
      {
          fn(one, two);
      }
  };
  
  
  int main()
  {
     aClass a;
     bClass b;
     auto fn_test1 = std::bind(&amp;aClass::test, a, _1, _2);
     auto fn_test2 = std::bind(&amp;bClass::test, b, _1, _2);
  
     testing test;
  
     test.test_me(fn_test1, 1, 2);
     test.test_me(fn_test2, 1, 2);
  }
  </code></pre>
  
  <p>Is there a way I can do this using a lambda instead?
  I know I can do this using std::bind but can I do this using a lambda and not have to do it each time for each member function I want to test (as below)?</p>