In my recent QA, I was suggested to implement my own is_same
for C++03 since the standard version is a part of C++11. The implementation was
template <typename T, typename U>
struct is_same {
static const bool value = false;
};
template <typename T>
struct is_same <T, T> {
static const bool value = true;
};
I want that it should be used only if it is not defined in the std
namespace. For instance, can it be wrapped in a preprocessor block like this ?
#if !defined(std::is_same)
// define is_same here
#endif
I want to avoid these errors
error: 'is_same' is not a member of 'std' // C++03
error: reference to 'is_same' is ambiguous // C++11