|
| 1 | +#pragma once |
1 | 2 | #ifndef TYPES_H |
2 | 3 | #define TYPES_H |
3 | 4 |
|
4 | | -// Type defs |
5 | | -typedef signed char s8; |
6 | | -typedef unsigned char u8; |
| 5 | +#include <cstdint> |
7 | 6 |
|
8 | | -typedef signed short s16; |
9 | | -typedef unsigned short u16; |
| 7 | +// Type defs |
| 8 | +using s8 = std::int8_t; |
| 9 | +using u8 = std::uint8_t; |
10 | 10 |
|
11 | | -typedef signed int s32; |
12 | | -typedef unsigned int u32; |
| 11 | +using s16 = std::int16_t; |
| 12 | +using u16 = std::uint16_t; |
13 | 13 |
|
14 | | -typedef signed __int64 s64; |
15 | | -typedef unsigned __int64 u64; |
| 14 | +using s32 = std::int32_t; |
| 15 | +using u32 = std::uint32_t; |
16 | 16 |
|
17 | | -typedef float f32; |
18 | | -typedef double f64; |
| 17 | +using s64 = std::int64_t; |
| 18 | +using u64 = std::uint64_t; |
19 | 19 |
|
20 | | -typedef char* pstr; |
21 | | -typedef const char* pcstr; |
| 20 | +using f32 = float; |
| 21 | +using f64 = double; |
22 | 22 |
|
23 | | -// windoze stuff |
24 | | -#ifndef _WINDOWS_ |
25 | | -typedef int BOOL; |
26 | | -typedef pstr LPSTR; |
27 | | -typedef pcstr LPCSTR; |
28 | | -#define TRUE true |
29 | | -#define FALSE false |
30 | | -#endif |
| 23 | +using pstr = char*; |
| 24 | +using pcstr = const char*; |
31 | 25 |
|
32 | 26 | // Type limits |
33 | | -#define type_max(T) (std::numeric_limits<T>::max()) |
34 | | -#define type_min(T) (-std::numeric_limits<T>::max()) |
35 | | -#define type_zero(T) (std::numeric_limits<T>::min()) |
36 | | -#define type_epsilon(T) (std::numeric_limits<T>::epsilon()) |
37 | | - |
38 | | -#define int_max type_max(int) |
39 | | -#define int_min type_min(int) |
40 | | -#define int_zero type_zero(int) |
41 | | - |
42 | | -#define flt_max type_max(float) |
43 | | -#define flt_min type_min(float) |
44 | | - |
45 | | -#define flt_zero type_zero(float) |
46 | | -#define flt_eps type_epsilon(float) |
47 | | - |
48 | | -#define dbl_max type_max(double) |
49 | | -#define dbl_min type_min(double) |
50 | | -#define dbl_zero type_zero(double) |
51 | | -#define dbl_eps type_epsilon(double) |
52 | | - |
53 | | -typedef char string16[16]; |
54 | | -typedef char string32[32]; |
55 | | -typedef char string64[64]; |
56 | | -typedef char string128[128]; |
57 | | -typedef char string256[256]; |
58 | | -typedef char string512[512]; |
59 | | -typedef char string1024[1024]; |
60 | | -typedef char string2048[2048]; |
61 | | -typedef char string4096[4096]; |
62 | | - |
63 | | -typedef char string_path[2 * _MAX_PATH]; |
| 27 | +template <typename T> |
| 28 | +constexpr auto type_max = std::numeric_limits<T>::max(); |
| 29 | + |
| 30 | +template <typename T> |
| 31 | +constexpr auto type_min = -std::numeric_limits<T>::max(); |
| 32 | + |
| 33 | +template <typename T> |
| 34 | +constexpr auto type_zero = std::numeric_limits<T>::min(); |
| 35 | + |
| 36 | +template <typename T> |
| 37 | +constexpr auto type_epsilon = std::numeric_limits<T>::epsilon(); |
| 38 | + |
| 39 | +constexpr int int_max = type_max<int>; |
| 40 | +constexpr int int_min = type_min<int>; |
| 41 | +constexpr int int_zero = type_zero<int>; |
| 42 | + |
| 43 | +constexpr float flt_max = type_max<float>; |
| 44 | +constexpr float flt_min = type_min<float>; |
| 45 | +constexpr float flt_zero = type_zero<float>; |
| 46 | +constexpr float flt_eps = type_epsilon<float>; |
| 47 | + |
| 48 | +#define FLT_MAX flt_max |
| 49 | +#define FLT_MIN flt_min |
| 50 | + |
| 51 | +constexpr double dbl_max = type_max<double>; |
| 52 | +constexpr double dbl_min = type_min<double>; |
| 53 | +constexpr double dbl_zero = type_zero<double>; |
| 54 | +constexpr double dbl_eps = type_epsilon<double>; |
| 55 | + |
| 56 | +using string16 = char[16]; |
| 57 | +using string32 = char[32]; |
| 58 | +using string64 = char[64]; |
| 59 | +using string128 = char[128]; |
| 60 | +using string256 = char[256]; |
| 61 | +using string512 = char[512]; |
| 62 | +using string1024 = char[1024]; |
| 63 | +using string2048 = char[2048]; |
| 64 | +using string4096 = char[4096]; |
| 65 | + |
| 66 | +using string_path = char[2 * MAX_PATH]; |
64 | 67 |
|
65 | 68 | #endif |
0 commit comments