Commit 32623e8e authored by Sven Over's avatar Sven Over Committed by Facebook Github Bot 5

fix passing move-only types to via(Executor*, Func)

Summary: This diff fixes a problem with passing move-only types to folly::via.

Reviewed By: ericniebler

Differential Revision: D3254906

fb-gh-sync-id: 8a9c703a8db0ccf20b9fb4fe9b80ad6cdcb3e388
fbshipit-source-id: 8a9c703a8db0ccf20b9fb4fe9b80ad6cdcb3e388
parent 6bdad19f
......@@ -448,7 +448,7 @@ auto via(Executor* x, Func func)
-> Future<typename isFuture<decltype(func())>::Inner>
{
// TODO make this actually more performant. :-P #7260175
return via(x).then(func);
return via(x).then(std::move(func));
}
template <class T>
......
......@@ -495,3 +495,10 @@ TEST(ViaFunc, isSticky) {
x.run();
EXPECT_EQ(2, count);
}
TEST(ViaFunc, moveOnly) {
ManualExecutor x;
auto intp = folly::make_unique<int>(42);
EXPECT_EQ(42, via(&x, [intp = std::move(intp)] { return *intp; }).getVia(&x));
}
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