I need to be able to differentiate between data types which have the same sizes but different signed-ness properties. An example follows,
template <size_t N>
struct alias;
template<>
struct alias<sizeof(unsigned char)>{
using Type = unsigned char;
};
template<>
struct alias<sizeof(signed char)>{
using Type = signed char;
};
using uint8 = alias<1>::Type;
using int8 = alias<1>::Type; //This is supposed to be signed type
Since first specialization uses unsigned char and both signed and unsigned chars use the same size, alias<1>::Type
results returning unsigned char. But I want to be able to return same data type as both signed and unsigned.
I am also aware there are std::is_signed or std::is_unsigned under type_traits header file. I could not figure out how to use them in this context.
EDIT
Partial Complete Code
#define BYTE 1
template <size_t N>
struct alias;
#define REGISTER_ALIAS(X) \
template <> \
struct alias <sizeof(X)> { \
using Type = X; \
};
REGISTER_ALIAS(unsigned char)
REGISTER_ALIAS(signed char)
using int8 = alias<BYTE>::Type;
using uint8 = alias<BYTE>::Type;