Project: mesos
Issue MESOS-4611: Passing a lambda to dispatch() always matches the template returning void
The following idiom does not currently compile: {code} Future initialized = dispatch(pid, [] () -> Nothing { return Nothing(); }); {code} This seems non-intuitive because the following template exists for dispatch: {code} template Future dispatch(const UPID& pid, const std::function& f) { std::shared_ptr> promise(new Promise()); std::shared_ptr> f_( new std::function( [=](ProcessBase*) { promise->set(f()); })); internal::dispatch(pid, f_); return promise->future(); } {code} However, lambdas cannot be implicitly cast to a corresponding std::function type. To make this work, you have to explicitly type the lambda before passing it to dispatch. {code} std::function f = []() { return Nothing(); }; Future initialized = dispatch(pid, f); {code} We should add template support to allow lambdas to be passed to dispatch() without explicit typing.
Story points: 5