#include "tensorstore/util/future.h"
template <typename Executor,
         
 typename Callback,
         
 typename... FutureValue>
Future<UnwrapFutureType<std::remove_cvref_t<
    
std::invoke_result_t<Callback, FutureValue&...>>>>
tensorstore::MapFutureValue(Executor&executor,
                            
Callback&callback,
                            
Future<FutureValue>... future);

Returns a Future that resolves to callback(future.value()...) when all of the specified future objects become ready with non-error results. The callback is invoked using the specified executor.

If any of the future objects become ready with an error result, the error propagates to the returned Future.

Example:

Future<int> future_a = ...;
Future<int> future_b = ...;
Future<int> mapped_future = MapFutureValue(
    InlineExecutor{}, [](int a, int b) { return a + b; },
    future_a, future_b);
Parameters:
Executor &&executor

Executor with which to invoke the callback callback.

Callback &&callback

Callback function to be invoked as callback(future.result().value()...) when all of the future objects become ready with non-error results.

Future<FutureValue>... future

The Future objects to link.

Dchecks:

(!future.null() && ...)

Returns:

A Future<UnwrapFutureType<std::remove_cvref_t<U>>>, where U is the return type of the specified callback function.