From: Hans Fugal Date: Wed, 1 Jul 2015 22:42:50 +0000 (-0700) Subject: Future global fixup X-Git-Tag: v0.49.0~11 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=812f803cdda23edfd855b2d60f0d08477c427ede;p=folly.git Future global fixup Summary: This is three codemods: * `(folly::(Future|Promise|Try))` -> `\1` * `(Future|Promise|Try)` -> `\1` * add `using folly::Unit` statements where needed Then * undo false positives in javascript files and fibers::Promise cf D2201259, which this will land with Reviewed By: @djwatson Differential Revision: D2201801 --- diff --git a/folly/futures/Future-inl.h b/folly/futures/Future-inl.h index 0595310a..380b0069 100644 --- a/folly/futures/Future-inl.h +++ b/folly/futures/Future-inl.h @@ -470,27 +470,15 @@ Future makeFuture() { return makeFuture(Unit{}); } -// XXX why is the dual necessary here? Can't we just use perfect forwarding -// and capture func by reference always? template -auto makeFutureWith( - F&& func, - typename std::enable_if::value, bool>::type sdf) +auto makeFutureWith(F&& func) -> Future::type> { using LiftedResult = typename Unit::Lift::type; - return makeFuture(makeTryWith([&func]() { - return (func)(); + return makeFuture(makeTryWith([&func]() mutable { + return func(); })); } -template -auto makeFutureWith(F const& func) - -> Future::type> { - F copy = func; - using LiftedResult = typename Unit::Lift::type; - return makeFuture(makeTryWith(std::move(copy))); -} - template Future makeFuture(std::exception_ptr const& e) { return makeFuture(Try(e)); diff --git a/folly/futures/helpers.h b/folly/futures/helpers.h index 0d0b881c..3b762732 100644 --- a/folly/futures/helpers.h +++ b/folly/futures/helpers.h @@ -77,13 +77,7 @@ Future makeFuture(); /** Make a completed Future by executing a function. If the function throws we capture the exception, otherwise we capture the result. */ template -auto makeFutureWith( - F&& func, - typename std::enable_if::value, bool>::type sdf) - -> Future::type>; - -template -auto makeFutureWith(F const& func) +auto makeFutureWith(F&& func) -> Future::type>; /// Make a failed Future from an exception_ptr.