From: Yedidya Feldblum Date: Wed, 7 Jun 2017 21:39:54 +0000 (-0700) Subject: Pass Try by rvalue ref in onError implementation X-Git-Tag: v2017.06.12.00~17 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=4aa6bf94e48f7fea2212b9b3a4f55784173dd17b;p=folly.git Pass Try by rvalue ref in onError implementation Summary: [Folly] Pass `Try` by rvalue ref in `onError` implementation. As is done in other overloads and in `thenImplementation`. For consistency. Reviewed By: spacedentist Differential Revision: D5199302 fbshipit-source-id: c78db0c36fc7a0b846ca5e44fc237422c9203a24 --- diff --git a/folly/futures/Future-inl.h b/folly/futures/Future-inl.h index 79b73a07..2a8b56b8 100644 --- a/folly/futures/Future-inl.h +++ b/folly/futures/Future-inl.h @@ -416,7 +416,7 @@ Future::onError(F&& func) { if (tf2.hasException()) { state.setException(std::move(tf2.exception())); } else { - tf2->setCallback_([p = state.stealPromise()](Try t3) mutable { + tf2->setCallback_([p = state.stealPromise()](Try && t3) mutable { p.setTry(std::move(t3)); }); } @@ -444,7 +444,7 @@ Future::onError(F&& func) { auto f = p.getFuture(); setCallback_( [state = detail::makeCoreCallbackState( - std::move(p), std::forward(func))](Try t) mutable { + std::move(p), std::forward(func))](Try && t) mutable { if (t.hasException()) { state.setTry(makeTryWith( [&] { return state.invoke(std::move(t.exception())); }));