| 1 | #pragma once | 
|---|
| 2 | #include <cstdint> | 
|---|
| 3 | #include <cstdlib> | 
|---|
| 4 | #include <type_traits> | 
|---|
| 5 | #include <algorithm> | 
|---|
| 6 |  | 
|---|
| 7 | using Int8 = int8_t; | 
|---|
| 8 | using Int16 = int16_t; | 
|---|
| 9 | using Int32 = int32_t; | 
|---|
| 10 | using Int64 = int64_t; | 
|---|
| 11 |  | 
|---|
| 12 | using UInt8 = uint8_t; | 
|---|
| 13 | using UInt16 = uint16_t; | 
|---|
| 14 | using UInt32 = uint32_t; | 
|---|
| 15 | using UInt64 = uint64_t; | 
|---|
| 16 |  | 
|---|
| 17 | /// The standard library type traits, such as std::is_arithmetic, with one exception | 
|---|
| 18 | /// (std::common_type), are "set in stone". Attempting to specialize them causes undefined behavior. | 
|---|
| 19 | /// So instead of using the std type_traits, we use our own version which allows extension. | 
|---|
| 20 | template <typename T> | 
|---|
| 21 | struct is_signed | 
|---|
| 22 | { | 
|---|
| 23 | static constexpr bool value = std::is_signed_v<T>; | 
|---|
| 24 | }; | 
|---|
| 25 |  | 
|---|
| 26 | template <typename T> | 
|---|
| 27 | inline constexpr bool is_signed_v = is_signed<T>::value; | 
|---|
| 28 |  | 
|---|
| 29 | template <typename T> | 
|---|
| 30 | struct is_unsigned | 
|---|
| 31 | { | 
|---|
| 32 | static constexpr bool value = std::is_unsigned_v<T>; | 
|---|
| 33 | }; | 
|---|
| 34 |  | 
|---|
| 35 | template <typename T> | 
|---|
| 36 | inline constexpr bool is_unsigned_v = is_unsigned<T>::value; | 
|---|
| 37 |  | 
|---|
| 38 | template <typename T> | 
|---|
| 39 | struct is_integral | 
|---|
| 40 | { | 
|---|
| 41 | static constexpr bool value = std::is_integral_v<T>; | 
|---|
| 42 | }; | 
|---|
| 43 |  | 
|---|
| 44 | template <typename T> | 
|---|
| 45 | inline constexpr bool is_integral_v = is_integral<T>::value; | 
|---|
| 46 |  | 
|---|
| 47 | template <typename T> | 
|---|
| 48 | struct is_arithmetic | 
|---|
| 49 | { | 
|---|
| 50 | static constexpr bool value = std::is_arithmetic_v<T>; | 
|---|
| 51 | }; | 
|---|
| 52 |  | 
|---|
| 53 | template <typename T> | 
|---|
| 54 | inline constexpr bool is_arithmetic_v = is_arithmetic<T>::value; | 
|---|
| 55 |  | 
|---|
| 56 |  | 
|---|