]> git.tdb.fi Git - libs/core.git/blobdiff - source/core/inttypes.h
Provide a way to get an integer type matching the size of another type
[libs/core.git] / source / core / inttypes.h
index 3bdac35c160925aae2a0b3aef5c6b45a66cdefa0..58debd00f67542ed751bacc4f320789948f83c83 100644 (file)
@@ -46,6 +46,11 @@ struct Int
        typedef typename TypeChooser<PlatformUnsignedTypes, Predicate>::Type UnsignedType;
 };
 
+/** A helper for choosing an integer that's the same size as another type. */
+template<typename T>
+struct MatchingInt: Int<sizeof(T)*CHAR_BIT>
+{ };
+
 // Finally define convenient shorthands for the actual integer types
 typedef Int<8>::SignedType Int8;
 typedef Int<8>::UnsignedType UInt8;
@@ -55,6 +60,7 @@ typedef Int<32>::SignedType Int32;
 typedef Int<32>::UnsignedType UInt32;
 typedef Int<64>::SignedType Int64;
 typedef Int<64>::UnsignedType UInt64;
+typedef MatchingInt<void *>::UnsignedType IntPtr;
 
 } // namespace Msp