#include #include #include #include #ifndef CT_ASSERT #define CT_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) #endif //CT_ASSERT namespace callable_traits { template static constexpr inline auto is_callable() { return std::integral_constant().value >= 0>{}; } template static constexpr inline auto is_callable(T&&) { return is_callable(); } } namespace ct = callable_traits; void foo() {} struct bar { template auto operator()(T&& t) { return t; } }; static_assert(ct::is_callable(foo), ""); static_assert(ct::is_callable(&foo), ""); static_assert(ct::is_callable(), ""); static_assert(ct::is_callable(), ""); static_assert(ct::is_callable(), ""); #ifndef CALLABLE_TRAITS_DISABLE_ARITY_RANGE static_assert(ct::is_callable(bar{}), ""); #endif //#ifndef CALLABLE_TRAITS_DISABLE_ARITY_RANGES int main() {}