Commit 7a960981 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot

Fix forwarding/moving in Futures reduce

Summary: [Folly] Fix forwarding/moving in Futures `reduce`.

Reviewed By: marshallcline

Differential Revision: D8601105

fbshipit-source-id: 96c1632821e9e5088a900ccecdaff9f8d108b905
parent 7a111f40
......@@ -1720,13 +1720,13 @@ Future<T> reduce(It first, It last, T&& initial, F&& func) {
Arg;
typedef isTry<Arg> IsTry;
auto sfunc = std::make_shared<F>(std::move(func));
auto sfunc = std::make_shared<std::decay_t<F>>(std::forward<F>(func));
auto f = first->then([minitial = std::forward<T>(initial),
sfunc](Try<ItT>&& head) mutable {
return (*sfunc)(
std::forward<T>(minitial), head.template get<IsTry::value, Arg&&>());
});
auto f = first->then(
[initial = std::forward<T>(initial), sfunc](Try<ItT>&& head) mutable {
return (*sfunc)(
std::move(initial), head.template get<IsTry::value, Arg&&>());
});
for (++first; first != last; ++first) {
f = collectAllSemiFuture(f, *first).toUnsafeFuture().then(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment