-
-
Save Rapptz/f756f50610af91f2b29d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<typename Function, typename Signature> | |
struct is_callable : std::false_type { | |
static_assert(std::is_function<Signature>::value, "Signature must be a function type"); | |
}; | |
struct is_callable_impl { | |
template<typename Function, typename Return, typename... Args, | |
typename R = decltype(std::declval<Function>()(std::declval<Args>()...))> | |
static std::is_same<Return, R> test(int); | |
template<typename...> | |
static std::false_type test(...); | |
}; | |
template<typename Function, typename Return, typename... Args> | |
struct is_callable<Function, Return(Args...)> : public decltype(is_callable_impl::test<Function, Return, Args...>(0)) {}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment