std::experimental::when_all
combines a collection of futures
into a single future that becomes ready when all of
the futures in the set become ready. For this overload, the collection
of futures is supplied as an iterator range.
template<typename Iterator> std::experimental::future<std::vector<typename std::iterator_traits<Iterator>::value_type> > when_all(Iterator begin,Iterator end);
std::iterator_traits<Iterator>::value_type
is an instantiation
of either std::experimental::future
or std::experimental::shared_future
. For each
value in the range [begin
,end
) a call to valid()
must return true
.
The futures in the supplied range are transferred into internal storage.
The asynchronous result associated with each future is marked so
that when all of the futures are ready the future
returned from when_all
is ready. If all of the futures are already
ready at the point of the call, the returned
future will also be ready. If std::iterator_traits<Iterator>::value_type
is an instantiation
of std::experimental::future
, then the futures
are moved into the internal storage, otherwise they are copied.
A std::experimental::future<std::vector<std::iterator_traits<Iterator>::value_type>
>
which becomes ready
when all of the futures in the supplied range becomes ready.
When the future is ready, the stored value is
a std::vector
holding the supplied futures
in the same order they were present in the original sequence.
The marking of each of the futures as ready
synchronizes with any call to wait()
or get()
on the returned future that sees
the result as ready.
std::bad_alloc
if the required internal
storage cannot be allocated.
#include <experimental/future>