title: C++ vector push_back with pointer to function
body: <p>I have a class <code>Foo</code> which contains a <code>vector</code> of <code>Bar</code>s:</p>
  
  <pre><code>class Foo
  {
  public:
      void create();
      void callback();
  
      std::vector&lt;Bar&gt; mBars;
  }
  </code></pre>
  
  <p>My <code>Bar</code> class contains this constructor:</p>
  
  <pre><code>class Bar
  {
      Bar(const int x, const int y, std::function&lt;void()&gt; &amp;callback);
  }
  </code></pre>
  
  <p>My <code>Foo</code> class has a <code>create()</code> method that adds <code>Bar</code>s to the <code>mBars</code> vector:</p>
  
  <pre><code>void Foo::create()
  {
      mBars.push_back({ 1224, 26, callback }); //ERROR!
  }
  </code></pre>
  
  <p>How can I set the function pointer, using <code>std::function</code>? and also without creating a separate object and <code>push_back</code> into the vector? Like the line above, where I get the error:</p>
  
  <pre><code>E0304   no instance of overloaded function "std::vector&lt;_Ty, _Alloc&gt;::push_back [with _Ty=CV::Button, _Alloc=std::allocator&lt;Bar&gt;]" matches the argument list    
  </code></pre>