Grindstone Game Engine v0.2.0
An open source game engine and toolkit.
Loading...
Searching...
No Matches
EnumTraits.hpp
1#pragma once
2
3#define GS_ENUM_FLAGS_FUNCS(T) \
4 inline T operator~(const T stages) {\
5 using UnderlyingType = std::underlying_type_t<T>;\
6 return static_cast<T>(~static_cast<UnderlyingType>(stages));\
7 }\
8 \
9 inline T operator|(const T a, const T b) {\
10 using UnderlyingType = std::underlying_type_t<T>;\
11 return static_cast<T>(static_cast<UnderlyingType>(a) | static_cast<UnderlyingType>(b));\
12 }\
13 \
14 inline T operator&(const T a, const T b) {\
15 using UnderlyingType = std::underlying_type_t<T>;\
16 return static_cast<T>(static_cast<UnderlyingType>(a) & static_cast<UnderlyingType>(b));\
17 }\
18 \
19 inline T operator^(const T a, const T b) {\
20 using UnderlyingType = std::underlying_type_t<T>;\
21 return static_cast<T>(static_cast<UnderlyingType>(a) ^ static_cast<UnderlyingType>(b));\
22 }\
23 \
24 inline T& operator|=(T& a, const T b) {\
25 a = a | b;\
26 return a;\
27 }\
28 \
29 inline T& operator&=(T& a, const T b) {\
30 a = a & b;\
31 return a;\
32 }\
33 \
34 inline T& operator^=(T& a, const T b) {\
35 a = a ^ b;\
36 return a;\
37 }\
38 \
39 inline bool Any(T v) {\
40 using UnderlyingType = std::underlying_type_t<T>;\
41 return static_cast<UnderlyingType>(v) != 0;\
42 }
43
44template <typename Enum>
45struct EnumTraits {
46 static constexpr const char* names[] = {};
47 static constexpr size_t size = 0;
48};
49
50template <typename Enum>
52 static constexpr const char* names[] = {};
53 static constexpr size_t size = 0;
54};
Definition EnumTraits.hpp:51
Definition EnumTraits.hpp:45