0

I'm trying to do a constexpr to check whether type F is a callable object or not. Since the callable object can be a generic lambda it seems to be quite difficult to determine whether or not F is callable without knowing what arguments it might take. For non-templated types F I was using the following traits:

template<class F, class... Args>
struct is_callable
{
    template<class U> static auto test(U* p) -> decltype((*p)(std::declval<Args>()...), void(), std::true_type());
    template<class U> static auto test(...) -> decltype(std::false_type());

    static constexpr bool value = decltype(test<F>(0))::value;
};

Is there a way to check whether type F has ANY call operator signature without having to provide Args.

Andreas Loanjoe
  • 2,205
  • 10
  • 26

0 Answers0