|
@@ -1,42 +1,15 @@
|
|
#ifndef TYPES_H
|
|
#ifndef TYPES_H
|
|
#define TYPES_H
|
|
#define TYPES_H
|
|
|
|
|
|
-namespace NumberSize {
|
|
|
|
- template<bool condition, typename IfTrue, typename IfFalse>
|
|
|
|
- struct Conditional {
|
|
|
|
- typedef IfTrue dummy;
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- template<typename IfTrue, typename IfFalse>
|
|
|
|
- struct Conditional<false, IfTrue, IfFalse> {
|
|
|
|
- typedef IfFalse dummy;
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- template<int N, typename A, typename B>
|
|
|
|
- using SizeCheck = Conditional<sizeof(A) == N, A, B>;
|
|
|
|
-
|
|
|
|
- template<int N>
|
|
|
|
- using Signed =
|
|
|
|
- SizeCheck<N, long long,
|
|
|
|
- typename SizeCheck<
|
|
|
|
- N, long, typename SizeCheck<N, int, typename SizeCheck<N, short, char>::dummy>::dummy>::dummy>;
|
|
|
|
-
|
|
|
|
- template<int N>
|
|
|
|
- using Unsigned =
|
|
|
|
- SizeCheck<N, unsigned long long,
|
|
|
|
- typename SizeCheck<
|
|
|
|
- N, unsigned long,
|
|
|
|
- typename SizeCheck<N, unsigned int,
|
|
|
|
- typename SizeCheck<N, unsigned short, unsigned char>::dummy>::dummy>::dummy>;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-typedef NumberSize::Signed<8>::dummy int64;
|
|
|
|
-typedef NumberSize::Signed<4>::dummy int32;
|
|
|
|
-typedef NumberSize::Signed<2>::dummy int16;
|
|
|
|
-typedef NumberSize::Signed<1>::dummy int8;
|
|
|
|
-typedef NumberSize::Unsigned<8>::dummy uint64;
|
|
|
|
-typedef NumberSize::Unsigned<4>::dummy uint32;
|
|
|
|
-typedef NumberSize::Unsigned<2>::dummy uint16;
|
|
|
|
-typedef NumberSize::Unsigned<1>::dummy uint8;
|
|
|
|
|
|
+#include <cinttypes>
|
|
|
|
+
|
|
|
|
+typedef int64_t int64;
|
|
|
|
+typedef int32_t int32;
|
|
|
|
+typedef int16_t int16;
|
|
|
|
+typedef int8_t int8;
|
|
|
|
+typedef uint64_t uint64;
|
|
|
|
+typedef uint32_t uint32;
|
|
|
|
+typedef uint16_t uint16;
|
|
|
|
+typedef uint8_t uint8;
|
|
|
|
|
|
#endif
|
|
#endif
|