#include #include #ifndef EXAMPLE_ADAPTORS_HPP #define EXAMPLE_ADAPTORS_HPP namespace example { namespace ct = callable_traits; //`make_function` turns any (non-overloaded) callable into std::function template inline decltype(auto) make_function(T&& t) { using signature = ct::function_type; using result_type = std::function; return result_type{ ::std::forward(t) }; } //this `make_function` overload turns a bind expression into std::function template inline decltype(auto) make_function(T&& t, First&& first, Others&&... others) { using bind_expr = decltype(::callable_traits::bind( ::std::forward(t), ::std::forward(first), ::std::forward(others)... )); using signature = ct::function_type; using result_type = std::function; return result_type{ ::std::bind( ::std::forward(t), ::std::forward(first), ::std::forward(others)... )}; } } #endif