On 9/6/2015 1:35 PM, Peter Dimov wrote:
Hartmut Kaiser wrote:
template <typename Future...> requires(is_future<Future>)... future
> when_all(Future &&... f) { (await f)...; return make_tuple(std::forward<Future>(f)...); } I've always found when_any much more interesting than when_all. Is it as trivial to implement with await as when_all?
The await proposal already deals with heterogeneous futures (awaitable types). It comes with traits and customization points on top of which it is built. Using `await_suspend` one can attach a callback to an awaitable object that fires when the future becomes ready (without consuming it). An heterogeneous `when_all` would be built on top of `await_suspend`, plain `await` is optimal when one just want the semantic of `when_all`. Similarly, an heterogeneous `when_any` would use `await_suspend` to attach a callback to all awaitable objects, and the first callback to run would make the resulting future ready (potentially but not necessarily canceling all other callbacks). Regards, -- Agustín K-ballo Bergé.- http://talesofcpp.fusionfenix.com