title: std::async variant which works over a collection
body: <p>Using <code>std::async</code> I was wondering whether it is possible to have a helper function, which creates <code>std::future</code>s from a collection (one future for every collection element).</p>
  
  <p>Often I have the following situation:</p>
  
  <pre><code>auto func = []( decltype(collection)::reference value ) {
    //Some async work
  };
  
  typedef std::result_of&lt;decltype(func)&gt;::type ResultType;
  std::vector&lt;std::future&lt;ResultType&gt;&gt; futures;
  futures.reserve(collection.size());
  
  // Create all futures
  for( auto&amp; element : collection ) {
    futures.push_back(std::async(func, element));
  }
  
  // Wait till futures are done
  for( auto&amp; future : futures ) {
    future.wait();
  }
  </code></pre>
  
  <p>To be able to easily reuse this I came up with the following partial code:</p>
  
  <pre><code>template&lt; class Function, class CT, class... Args&gt;
  std::vector&lt;std::future&lt;typename std::result_of&lt;Function(Args...)&gt;::type&gt;&gt;
  async_all( Function&amp;&amp; f, CT&amp; col ) {
  
      typedef typename std::result_of&lt;Function(Args...)&gt;::type ResultType;
      std::vector&lt;std::future&lt;ResultType&gt;&gt; futures;
      futures.reserve(collection.size());
  
      for( auto&amp; element : collection ) {
          futures.push_back(std::async(func, element));
      }
  }
  return futures;
  </code></pre>
  
  <p>Now I have to solve the <code>Args</code> problem, since in <code>async_all</code>, <code>Args</code> cannot be deduced anymore. The only thing I currently can think of is another functor, which converts an element in collection to <code>Args</code>.
  Is there any more elegant solution to this?</p>