In some situations it\'s desirable to be able to type-erase a callable (e.g. function, function pointer, object instance with operator(), lambda, mem_fn>
I've come up with a fairly nasty non-library solution, using the fact that lambdas have operator():
template struct remove_class { };
template
struct remove_class { using type = R(A...); };
template
struct remove_class { using type = R(A...); };
template
struct remove_class { using type = R(A...); };
template
struct remove_class { using type = R(A...); };
template
struct get_signature_impl { using type = typename remove_class<
decltype(&std::remove_reference::type::operator())>::type; };
template
struct get_signature_impl { using type = R(A...); };
template
struct get_signature_impl { using type = R(A...); };
template
struct get_signature_impl { using type = R(A...); };
template using get_signature = typename get_signature_impl::type;
template using make_function_type = std::function>;
template make_function_type make_function(F &&f) {
return make_function_type(std::forward(f)); }
Any ideas where this can be simplified or improved? Any obvious bugs?