1 #ifndef MSP_CORE_INTTYPES_H_
2 #define MSP_CORE_INTTYPES_H_
9 // Define lists of standard types, both signed and unsigned variants
10 typedef TypeList<signed char, short, int, long>::Type StandardSignedTypes;
11 typedef TypeList<unsigned char, unsigned short, unsigned int, unsigned long>::Type StandardUnsignedTypes;
13 // Then add possible nonstandard types
15 #if (__GNUC__>4 || (__GNUC__==4 && __GNUC_MINOR__>=6)) && defined(__LP64__)
16 #pragma GCC diagnostic push
18 #pragma GCC diagnostic ignored "-Wpedantic"
20 #pragma GCC diagnostic ignored "-pedantic"
22 typedef TypeList<StandardSignedTypes, long long, __int128>::Type PlatformSignedTypes;
23 typedef TypeList<StandardUnsignedTypes, unsigned long long, unsigned __int128>::Type PlatformUnsignedTypes;
24 #pragma GCC diagnostic pop
26 typedef TypeList<StandardSignedTypes, long long>::Type PlatformSignedTypes;
27 typedef TypeList<StandardUnsignedTypes, unsigned long long>::Type PlatformUnsignedTypes;
29 #elif defined(_MSC_VER)
30 typedef TypeList<StandardSignedTypes, __int64>::Type PlatformSignedTypes;
31 typedef TypeList<StandardUnsignedTypes, unsigned __int64>::Type PlatformUnsignedTypes;
33 typedef StandardSignedTypes PlatformSignedTypes;
34 typedef StandardUnsignedTypes PlatformUnsignedTypes;
37 /** A helper for choosing an integer type of a specific size. The size
38 parameter is in bits. The resulting types can be obtained from the SignedType
39 and UnsignedType typedefs. */
40 template<unsigned size>
46 enum { value = (sizeof(T)*CHAR_BIT==size) };
49 typedef typename TypeChooser<PlatformSignedTypes, Predicate>::Type SignedType;
50 typedef typename TypeChooser<PlatformUnsignedTypes, Predicate>::Type UnsignedType;
53 /** A helper for choosing an integer that's the same size as another type. */
55 struct MatchingInt: Int<sizeof(T)*CHAR_BIT>
58 // Finally define convenient shorthands for the actual integer types
59 typedef Int<8>::SignedType Int8;
60 typedef Int<8>::UnsignedType UInt8;
61 typedef Int<16>::SignedType Int16;
62 typedef Int<16>::UnsignedType UInt16;
63 typedef Int<32>::SignedType Int32;
64 typedef Int<32>::UnsignedType UInt32;
65 typedef Int<64>::SignedType Int64;
66 typedef Int<64>::UnsignedType UInt64;
67 typedef MatchingInt<void *>::UnsignedType IntPtr;