libcoro  1.0
Coroutine support library for C++20

◆ convert_to()

template<typename T >
template<typename X , std::invocable< cast_ret_value > Fn>
promise<X>::notify coro::future< T >::convert_to ( promise< X > &  prom,
Fn &&  convert 
)
inlinenoexcept

Forward value, possibly convert it, to different promise.

The source future must be resolved. The function forwards whole state without throwing any exception. So the target promise recives possible exception or cancel status

Parameters
promtarget promise
convertfunction which perform conversion from T to X. For T=void, the passed value is bool. If the function returns void, default constructor is used to construct result
Returns
notify of target promise. If the future is not resulved, return is false

Definition at line 904 of file future.h.