Search code examples
c++templatestype-traits

How do I check if my template class is a specific classtype?


In my function template, I'm trying to check whether the type T is a specific type. How would I do that?

template<class T> int foo(T a) {
  // check if T of type, say, String?
}

Solution

  • I suppose you could use the std::type_info returned by the typeid operator