title: C++, match custom placeholders with function arguments
body: <p>I am trying to write the piece of code which will do the following: let's assume we have a call of custom bind function </p>
  
  <pre><code>auto bind_obj = bind(some_func, _1, "test")  
  </code></pre>
  
  <p>and after we have </p>
  
  <pre><code>auto res = bind_obj(42) 
  </code></pre>
  
  <p>where the function some_func: </p>
  
  <pre><code>int some_func(int val, string test)
  </code></pre>
  
  <p>How can it possible to match placeholders with arguments provided in actual function call, i.e. bind_obj(...)??</p>
  
  <p>In other words, is it possible to iterate over std::tuple (arguments and placeholders here) and variadic pack (function arguments) to:</p>
  
  <ol>
  <li>deduce the return type of function some_func;</li>
  <li>make correct std::tuple to further use it in some_func() call ?</li>
  </ol>
  
  <p>I am trying to do this not using boost and std::functional. I think, my main problem is that i don't understand how to build tuple at runtime with arguments (where all the placeholders replaced correctly) and to deduce return type. </p>
  
  <p>I saw _Mu template structure in STL "functional.h" but it looks too complex and overloaded.         </p>