Commit 62b1d047 authored by Eric Niebler's avatar Eric Niebler Committed by Facebook Github Bot 0

rearrange folly::Function so that its template arguments are deducable.

Summary:
`folly::Function` was an alias to a more complex type with template arguments that could not be deduced. For example, the call to `foo` below was failing to compile.

```
template <class R, class... As>
void foo(folly::Function<R(As...)> f) {
}

int main() {
  foo( folly::Function<void(int)>{ [](int i){} } );
}
```

Rearrange the code so that folly::Function is no longer an alias, thus making its template arguments deducable.

Reviewed By: luciang, spacedentist

Differential Revision: D3256130

fb-gh-sync-id: fb403e48d161635b3b7f36e53b1679eb46cbfe7f
fbshipit-source-id: fb403e48d161635b3b7f36e53b1679eb46cbfe7f
parent a6fd9a69
This diff is collapsed.
......@@ -49,6 +49,10 @@ struct Functor {
return oldvalue;
}
};
template <typename Ret, typename... Args>
void deduceArgs(Function<Ret(Args...)>) {}
} // namespace
// TEST =====================================================================
......@@ -849,3 +853,9 @@ TEST(Function, SelfMoveAssign) {
f = std::move(g);
EXPECT_TRUE(f);
}
TEST(Function, DeducableArguments) {
deduceArgs(Function<void()>{[] {}});
deduceArgs(Function<void(int, float)>{[](int, float) {}});
deduceArgs(Function<int(int, float)>{[](int i, float) { return i; }});
}
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