title: Using std::bind to bind parameters and object instance separately
body: <p>Is it possible to bind arguments to a member function call, and later bind the target object separately?</p>
  
  <p>What I was trying to achieve is a helper function which receives a function with arbitrary arguments as an argument, and then executes it on all items in a collection.</p>
  
  <pre><code>void SomeType::Work(UINT a, UINT b, UINT c)
  {
      //do something
  }
  
  template&lt;typename Function, class Container&gt;
  void Execute(const Function&amp; fn, const Container&amp; collection)
  {
      for(auto&amp; item : collection)
      {
          auto bound = std::bind(fn, &amp;item);
          bound();
      }
  }
  
  void Test()
  {
      //eg. container = vector of SomeType
      auto fn = std::bind(&amp;Sometype::Work, 10, 20, 30);
      Execute(fn, container);
  }
  </code></pre>
  
  <p>This was failing with some error within functional:</p>
  
  <pre><code>error C2064: term does not evaluate to a function taking 3 arguments
  </code></pre>
  
  <p>Eventually pointing at:</p>
  
  <pre><code>see reference to function template instantiation 'void Execute&lt;std::_Bind&lt;true,void,std::_Pmf_wrap&lt;void (__thiscall SomeType::* )(UINT,UINT,UINT),void,SomeType,UINT,UINT,UINT&gt;,UINT &amp;,UINT &amp;,UINT &amp;&gt;&gt;(const Function &amp;)' being compiled
  with
  [
      Function=std::_Bind&lt;true,void,std::_Pmf_wrap&lt;void (__thiscall SomeType::* )(UINT,UINT,UINT),void,SomeType,UINT,UINT,UINT&gt;,UINT &amp;,UINT &amp;,UINT &amp;&gt;
  ]
  </code></pre>
  
  <p>I worked around it by just passing in a lambda that captures the desired values and executes the desired function on an object passed into it. I'm still left wondering if binding functions this way has any legs and I was just going about it wrong, or if it's just not doable.</p>