how to do an if else depending type of type in c++ template? [duplicate]

You could use typeid:

if (typeid(T) == typeid(int))

Or you could use the std::is_same type trait:

if (std::is_same<T, int>::value)

Leave a Comment