You can simply use the special template specialization.
#include <stdio.h> template<typename T> struct func_with_zero_args { static const bool value = false; }; template<> struct func_with_zero_args <int (*)()> { static const bool value = true; }; #define STRINGIFY(t) "" #t #define TEST(t) printf(STRINGIFY(t) ": %s\n", (func_with_zero_args<t>::value ? "yes" : "no")); int main(int argc, const char* argv[]) { TEST(void); TEST(void (*)(void)); TEST(void (*)(int)); TEST(int (*)(void)); TEST(int (*)(int)); return 0; }
Creates (using g ++ (Ubuntu / Linaro 4.7.3-1ubuntu1) 4.7.3)
void: no
void (*) (void): no
void (*) (int): no
int (*) (void): yes
int (*) (int): no
source share