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<T,U>::value will be true if T and U are the same type, false otherwise.
std::is_same
std::is_same<T,U>::value
If you don't have C++11, it's easy to implement as this
template<class T, class U> struct is_same { enum { value = 0 }; }; template<class T> struct is_same<T, T> { enum { value = 1 }; };