• Sven Over's avatar
    folly::Function: improve conversion of return types · ecf14e67
    Sven Over authored
    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
    ecf14e67
Function.h 20.1 KB