Use explicit sized integer types for sign_types<T>
When we used size_t/ssize_t they conflicted with the system's word sized integers. This should work well for all the numeric types we're likely to see.
This commit is contained in:
parent
165cd18c0c
commit
128d46d9ad
48
types.hpp
48
types.hpp
@ -58,27 +58,51 @@ template <typename T>
|
|||||||
struct sign_types;
|
struct sign_types;
|
||||||
|
|
||||||
|
|
||||||
template <> struct sign_types <signed int> {
|
template <> struct sign_types <int8_t> {
|
||||||
typedef signed int with_sign;
|
typedef int8_t with_sign;
|
||||||
typedef unsigned int without_sign;
|
typedef uint8_t without_sign;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template <> struct sign_types <unsigned int> {
|
template <> struct sign_types <uint8_t> {
|
||||||
typedef signed int with_sign;
|
typedef int8_t with_sign;
|
||||||
typedef unsigned int without_sign;
|
typedef uint8_t without_sign;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template <> struct sign_types <ssize_t> {
|
template <> struct sign_types <int16_t> {
|
||||||
typedef ssize_t with_sign;
|
typedef int16_t with_sign;
|
||||||
typedef size_t without_sign;
|
typedef uint16_t without_sign;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template <> struct sign_types <size_t> {
|
template <> struct sign_types <uint16_t> {
|
||||||
typedef ssize_t with_sign;
|
typedef int16_t with_sign;
|
||||||
typedef size_t without_sign;
|
typedef uint16_t without_sign;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <> struct sign_types <int32_t> {
|
||||||
|
typedef int32_t with_sign;
|
||||||
|
typedef uint32_t without_sign;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <> struct sign_types <uint32_t> {
|
||||||
|
typedef int32_t with_sign;
|
||||||
|
typedef uint32_t without_sign;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <> struct sign_types <int64_t> {
|
||||||
|
typedef signed long with_sign;
|
||||||
|
typedef unsigned long without_sign;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <> struct sign_types <uint64_t> {
|
||||||
|
typedef signed long with_sign;
|
||||||
|
typedef unsigned long without_sign;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user