boost::capy::when_any
when_any overloads
Synopses
Declared in <boost/capy/when_any.hpp>
Race io_result‐returning awaitables, selecting the first success.
template<IoAwaitable... As>
requires (sizeof...(As) > 0)
&& detail::all_io_result_awaitables<As...>
[[nodiscard]]
task<std::variant<std::error_code, /* implementation-defined */...>>
when_any(As... as);
Race a range of io_result‐returning awaitables (non‐void payloads).
template<IoAwaitableRange R>
requires detail::is_io_result_v<
awaitable_result_t<std::ranges::range_value_t<R>>>
&& (!std::is_same_v<
detail::io_result_payload_t<
awaitable_result_t<std::ranges::range_value_t<R>>>,
std::tuple<>>)
[[nodiscard]]
task<std::variant<std::error_code, std::pair<std::size_t, /* implementation-defined */>>>
when_any(R&& awaitables);
Race a range of void io_result‐returning awaitables.
template<IoAwaitableRange R>
requires detail::is_io_result_v<
awaitable_result_t<std::ranges::range_value_t<R>>>
&& std::is_same_v<
detail::io_result_payload_t<
awaitable_result_t<std::ranges::range_value_t<R>>>,
std::tuple<>>
[[nodiscard]]
task<std::variant<std::error_code, std::size_t>>
when_any(R&& awaitables);
Exceptions
Name |
Thrown on |
|
the winner's exception if extracting or constructing the winning payload throws (a winner was found but its result could not be produced). |
|
if range is empty. |
Return Value
-
A task yielding variant<error_code, R1, ..., Rn> where index 0 is the failure/no‐winner case and index i+1 identifies the winning child. On all‐fail, index 0 holds an error_code from one of the failed children (unspecified which; no priority between errors and exceptions).
-
A task yielding variant<error_code, pair<size_t, PayloadT>> where index 0 is failure and index 1 carries the winner's index and payload.
-
A task yielding variant<error_code, size_t> where index 0 is failure and index 1 carries the winner's index.
Parameters
Name |
Description |
as |
The awaitables to race. Each must satisfy |
awaitables |
Range of io_result‐returning awaitables (must not be empty). |
See Also
IoAwaitableRange, when_any
Created with MrDocs