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
17 #pragma GCC diagnostic ignored "-pedantic"
18 typedef TypeList<StandardSignedTypes, long long, __int128>::Type PlatformSignedTypes;
19 typedef TypeList<StandardUnsignedTypes, unsigned long long, unsigned __int128>::Type PlatformUnsignedTypes;
20 #pragma GCC diagnostic pop
22 typedef TypeList<StandardSignedTypes, long long>::Type PlatformSignedTypes;
23 typedef TypeList<StandardUnsignedTypes, unsigned long long>::Type PlatformUnsignedTypes;
25 #elif defined(_MSC_VER)
26 typedef TypeList<StandardSignedTypes, __int64>::Type PlatformSignedTypes;
27 typedef TypeList<StandardUnsignedTypes, unsigned __int64>::Type PlatformUnsignedTypes;
29 typedef StandardSignedTypes PlatformSignedTypes;
30 typedef StandardUnsignedTypes PlatformUnsignedTypes;
33 /** A helper for choosing an integer type of a specific size. The size
34 parameter is in bits. The resulting types can be obtained from the SignedType
35 and UnsignedType typedefs. */
36 template<unsigned size>
42 enum { value = (sizeof(T)*CHAR_BIT==size) };
45 typedef typename TypeChooser<PlatformSignedTypes, Predicate>::Type SignedType;
46 typedef typename TypeChooser<PlatformUnsignedTypes, Predicate>::Type UnsignedType;
49 /** A helper for choosing an integer that's the same size as another type. */
51 struct MatchingInt: Int<sizeof(T)*CHAR_BIT>
54 // Finally define convenient shorthands for the actual integer types
55 typedef Int<8>::SignedType Int8;
56 typedef Int<8>::UnsignedType UInt8;
57 typedef Int<16>::SignedType Int16;
58 typedef Int<16>::UnsignedType UInt16;
59 typedef Int<32>::SignedType Int32;
60 typedef Int<32>::UnsignedType UInt32;
61 typedef Int<64>::SignedType Int64;
62 typedef Int<64>::UnsignedType UInt64;
63 typedef MatchingInt<void *>::UnsignedType IntPtr;