To meet your requirement, you must use the typeid operator. Then your expression will look like
if (typeid(T) == typeid(int)) { ... }
An obvious sample to illustrate that this really works:
#include <typeinfo> #include <iostream> template <typename T> class AClass { public: static bool compare() { return (typeid(T) == typeid(int)); } }; void main() { std::cout << AClass<char>::compare() << std::endl; std::cout << AClass<int>::compare() << std::endl; }
So you can, for example, get:
0 1
Keynslug
source share