What about this solution? A code with the function will be compiled if the type T is satisfied your requrements. Otherwise, the static assertion failed.
#include <type_traits>enum anEnum { //};template <typename T, bool defined = std::is_same<T, int>::value || std::is_same<T, anEnum>::value>bool isFunction(const T& aVariable){ static_assert(defined, "Invalid specialization"); bool result = false; // Put your code here return result;}