#ifndef IS_CALLABLE_H #define IS_CALLABLE_H #include /** * @brief Implementation of IsCallable */ template struct IsCallableImpl { private: typedef char(&yes)[1]; typedef char(&no)[2]; struct Fallback { void operator()(); }; struct Derived : T, Fallback { }; template struct Check; template static yes test(...); template static no test(Check*); public: static const bool value = sizeof(test(0)) == sizeof(yes); }; /** * @brief Checks if a type is callable * * Callable means here, that it has has an 'operator()'. This will not work for * normal functions without modifications, but we don't need that case anyway. * * See https://stackoverflow.com/a/15396757/7421666 */ template struct IsCallable : std::conditional< std::is_class::value, IsCallableImpl, std::false_type >::type { }; #endif // IS_CALLABLE_H