I'm developing some tests for the add_signed MPL class that converts the type to its signed counterpart. It is defined as follows:
template<class T>
struct add_signed {
typedef T type;
};
template<>
struct add_signed<std::uint8_t> {
typedef std::int8_t type;
};
template<>
struct add_signed<std::uint16_t> {
typedef std::int16_t type;
};
template<>
struct add_signed<std::uint32_t> {
typedef std::int32_t type;
};
template<>
struct add_signed<std::uint64_t> {
typedef std::int64_t type;
};
While testing on different types I noticed that the following evaluates to true:
std::is_same<add_signed<uintptr_t>::type, intptr_t>::value // true
Similarly for the add_unsigned MPL class, the following code evaluates to true:
std::is_same<add_unsigned<intptr_t>::type, uintptr_t>::value // true
My compiler is MSVC 2010.
So the question is - can we assume that in all (sane) compilers signing intptr_t will produce uintptr_t and vice versa?