huy huy - 3 years ago 121
C++ Question

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

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

p/s I knew the template specification way but I don't want to do that.

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


Thanks!

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download