boost::capy::when_any

when_any overloads

Synopses

Declared in <boost/capy/when_any.hpp>

Wait for the first awaitable to complete (range overload).

template<IoAwaitableRange R>
requires (!std::is_void_v<detail::awaitable_result_t<std::ranges::range_value_t<R>>>)
[[nodiscard]]
task<std::pair<std::size_t, /* implementation-defined */>>
when_any(R&& awaitables);

Wait for the first awaitable to complete (void range overload).

template<IoAwaitableRange R>
requires std::is_void_v<detail::awaitable_result_t<std::ranges::range_value_t<R>>>
[[nodiscard]]
task<std::size_t>
when_any(R&& awaitables);

Wait for the first awaitable to complete.

template<
    IoAwaitable A0,
    IoAwaitable... As>
[[nodiscard]]
task</* implementation-defined */>
when_any(
    A0 a0,
    As... as);

Exceptions

Name

Thrown on

std::invalid_argument

if range is empty (thrown before coroutine suspends).

Rethrows

the winner's exception if the winning task threw an exception.

Return Value

  • A task yielding a pair of (winner_index, result).

  • A task yielding the winner's index (zero‐based).

  • A task yielding a pair of (winner_index, result_variant).

Template Parameters

Name Description

R

Range type satisfying IoAwaitableRange.

A0

First awaitable type (must satisfy IoAwaitable).

As

Remaining awaitable types (must satisfy IoAwaitable).

Parameters

Name Description

awaitables

Range of awaitables to race concurrently (must not be empty).

a0

The first awaitable to race.

as

Additional awaitables to race concurrently.

See Also

when_any, IoAwaitableRange

when_all, IoAwaitable

Created with MrDocs