How to check for the type of a template parameter?
Use is_same: #include <type_traits> template <typename T> void foo() { if (std::is_same<T, animal>::value) { /* … */ } // optimizable… } Usually, that’s a totally unworkable design, though, and you really want to specialize: template <typename T> void foo() { /* generic implementation */ } template <> void foo<animal>() { /* specific for T = … Read more