I was wondering if it is possible to check if 2 types are same at compile time. What I came up with is(idk if it works because it feels hackish and IDK standard that good so
Use std::is_same. std::is_same::value will be true if T and U are the same type, false otherwise.
std::is_same
std::is_same::value
If you don't have C++11, it's easy to implement as this
template struct is_same { enum { value = 0 }; }; template struct is_same { enum { value = 1 }; };