title: How to pass std::function as an argument to a mocked method in gmock?
body: <p>I am getting a runtime error when trying to pass an <code>std:function</code> as an argument to a mocked method inside <code>EXPECT_CALL</code>.
  I wish to verify that <code>Bar</code> is called with <code>callback</code> as an argument.</p>
  
  <p>Code:</p>
  
  <pre><code>#include &lt;gtest/gtest.h&gt;
  #include &lt;gmock/gmock.h&gt;
  
  class Foo {
  public:
      virtual void Bar(const std::function&lt;void (const std::string &amp;name)&gt; &amp;callback) = 0;
  };
  
  class MockFoo : public Foo {
  public:
      MOCK_METHOD(void, Bar, (const std::function&lt;void (const std::string &amp;name)&gt; &amp;callback));
  };
  
  TEST(FooBarTest, callback) {
      MockFoo foo;
  
      const std::function&lt;void(const std::string &amp;name)&gt; callback;
  
      EXPECT_CALL(foo, Bar(callback)).Times(1);
  
      foo.Bar(callback);
  }
  
  int main(int argc, char **argv) {
      testing::InitGoogleTest(&amp;argc, argv);
      return RUN_ALL_TESTS();
  }
  </code></pre>
  
  <p>An error is produced at runtime:</p>
  
  <pre><code>/usr/local/include/gtest/gtest-matchers.h:211:60: error: no match for ‘operator==’ (operand types are ‘const std::function&lt;void(const std::__cxx11::basic_string&lt;char&gt;&amp;)&gt;’ and ‘const std::function&lt;void(const std::__cxx11::basic_string&lt;char&gt;&amp;)&gt;’)
     bool operator()(const A&amp; a, const B&amp; b) const { return a == b; }
  </code></pre>