carb::cpp::is_invocable

Defined in carb/cpp/TypeTraits.h

template<typename Func, typename ...TArgs>
struct is_invocable : public detail::is_invocable_impl<void, Func, TArgs...>

Check if the Func is invocable with the TArgs pack.

If Func is callable with the given TArgs pack, then this structure will derive from true_type; otherwise, it will be false_type. If value is true, then invoke(func, args...) is a valid expression.

static_assert(is_invocable<void(*)()>::value);
static_assert(!is_invocable<void(*)(int)>::value);
static_assert(is_invocable<void(*)(int), int>::value);
static_assert(is_invocable<void(*)(long), int>::value);

This is equivalent to the C++20 std::is_invocable meta query. The query was added in C++17, but this additionally supports invoking a pointer to a const& member function on an rvalue reference.