#include #include // Defined in C++17. Needed by all checks template using void_t = void; // For each different member you want to check for, you need something like this template struct has_foo_member : std::false_type{}; template struct has_foo_member> : std::true_type{}; // Where you can use the aforementioned checks with enable_if template ::value>* = nullptr> void print_has_foo_member() { std::cout << "Class " << typeid(T).name() << ": has a foo member" << std::endl; } template ::value>* = nullptr> void print_has_foo_member() { std::cout << "Class " << typeid(T).name() << ": does not have a foo member" << std::endl; } // Here are some example classes we will check struct Empty { }; struct HasStaticFoo { static int foo; }; struct HasNonstaticFoo { double foo; }; struct HasFooMethod { double foo(){ return 1; }; }; int main() { print_has_foo_member(); print_has_foo_member(); print_has_foo_member(); print_has_foo_member(); }