| Technical Specification | ||||
| Filesystem library(filesystem TS) | ||||
| Library fundamentals(library fundamentals TS) | ||||
| Library fundamentals 2(library fundamentals TS v2) | ||||
| Library fundamentals 3(library fundamentals TS v3) | ||||
| Extensions for parallelism(parallelism TS) | ||||
| Extensions for parallelism 2(parallelism TS v2) | ||||
| Extensions for concurrency(concurrency TS) | ||||
| Extensions for concurrency 2(concurrency TS v2) | ||||
| Concepts(concepts TS) | ||||
| Ranges(ranges TS) | ||||
| Reflection(reflection TS) | ||||
| Mathematical special functions(special functions TR) | ||||
| Experimental Non-TS | ||||
| Pattern Matching | ||||
| Linear Algebra | ||||
| std::execution | ||||
| Contracts | ||||
| 2D Graphics |
| std::future extensions | ||||
experimental::when_any | ||||
| Latches and barriers | ||||
| Atomic smart pointers | ||||
Defined in header <experimental/future> | ||
template<class Sequence> struct when_any_result{ | (concurrency TS) | |
template<class InputIt> auto when_any( InputIt first, InputIt last) | (1) | (concurrency TS) |
template<class...Futures> auto when_any( Futures&&...futures) | (2) | (concurrency TS) |
Create afuture object that becomes ready when at least one of the inputfutures andshared_futures become ready. The behavior is undefined if any inputfuture orshared_future is invalid.
In particular, letSequence be astd::vector<typenamestd::iterator_traits<InputIt>::value_type> for(1) andstd::tuple<std::decay_t<Futures>...> for(2). This function template creates a shared state containingwhen_any_result<Sequence> and returns a future referring to the shared state. Every inputfuture is moved into the corresponding object in thefutures member of thewhen_any_result<Sequence> in the shared state, and every inputshared_future is copied to the corresponding object in thefutures member of thewhen_any_result<Sequence> in the shared state. The order of the objects in theSequence matches the order of arguments.
InputIt's value type (i.e.,typenamestd::iterator_traits<InputIt>::value_type) is astd::experimental::future orstd::experimental::shared_future.Fn inFutures, eitherstd::remove_reference_t<Fn> isstd::experimental::future<Rn>, orstd::decay_t<Fn> isstd::experimental::shared_future<Rn>.)After this call, every inputfuture is no longer valid; every inputshared_future remains valid.
Afuture referring to the shared state created by the call. The future is alwaysvalid(), and it becomes ready when at least one of the inputfutures andshared_futures the call are ready. Theindex member of thewhen_any_result contains the position of the readyfuture orshared_future in thefutures member.
future is ready immediately; thefutures field of thewhen_any_result is an empty vector, and theindex field issize_t(-1).future is ready immediately; thefutures field of thewhen_any_result is an empty tuple, and theindex field issize_t(-1).