folly::Function: improve conversion of return types
authorSven Over <over@fb.com>
Sat, 26 Mar 2016 09:10:46 +0000 (02:10 -0700)
committerFacebook Github Bot 7 <facebook-github-bot-7-bot@fb.com>
Sat, 26 Mar 2016 09:20:22 +0000 (02:20 -0700)
commitecf14e67a9f98b0548ce119f400b66e9a2c58a69
tree65a3d15f182245431410632b3c7b21753fb69721
parentb6ed6b394419ab079fa2ddfd2de053fb7f6e1b95
folly::Function: improve conversion of return types

Summary:Treat any return type as convertible to void:

As of C++17, std::function<void(Args...)> can be set to callables
returning non-void types when called with parameters Args....
This diff adds that capability to folly::Function. It also adds
unit tests, not only for ignoring return types, but also for
correctly converting between the return type of the embedded
callabled and the return type of the encapsulating folly::Function.

Allow conversion of one folly::Function type to another one which
declares a return type the original one can be converted to:

E.g. allow to construct a Function<double()> from a
Function<int()> or a Function<Base*()> from a
Function<Derived*()>.

Reviewed By: yfeldblum

Differential Revision: D3095583

fb-gh-sync-id: 6d924dc6e97f759d8109db4200e1cb9333a98d31
fbshipit-source-id: 6d924dc6e97f759d8109db4200e1cb9333a98d31
folly/Function-inl.h
folly/Function-pre.h
folly/Function.h
folly/test/FunctionTest.cpp