summaryrefslogtreecommitdiff
path: root/src/common/common_funcs.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/common_funcs.h')
-rw-r--r--src/common/common_funcs.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/common/common_funcs.h b/src/common/common_funcs.h
index 052254678..88cf5250a 100644
--- a/src/common/common_funcs.h
+++ b/src/common/common_funcs.h
@@ -55,6 +55,38 @@ __declspec(dllimport) void __stdcall DebugBreak(void);
55// Defined in Misc.cpp. 55// Defined in Misc.cpp.
56std::string GetLastErrorMsg(); 56std::string GetLastErrorMsg();
57 57
58#define DECLARE_ENUM_FLAG_OPERATORS(type) \
59 constexpr type operator|(type a, type b) noexcept { \
60 using T = std::underlying_type_t<type>; \
61 return static_cast<type>(static_cast<T>(a) | static_cast<T>(b)); \
62 } \
63 constexpr type operator&(type a, type b) noexcept { \
64 using T = std::underlying_type_t<type>; \
65 return static_cast<type>(static_cast<T>(a) & static_cast<T>(b)); \
66 } \
67 constexpr type& operator|=(type& a, type b) noexcept { \
68 using T = std::underlying_type_t<type>; \
69 a = static_cast<type>(static_cast<T>(a) | static_cast<T>(b)); \
70 return a; \
71 } \
72 constexpr type& operator&=(type& a, type b) noexcept { \
73 using T = std::underlying_type_t<type>; \
74 a = static_cast<type>(static_cast<T>(a) & static_cast<T>(b)); \
75 return a; \
76 } \
77 constexpr type operator~(type key) noexcept { \
78 using T = std::underlying_type_t<type>; \
79 return static_cast<type>(~static_cast<T>(key)); \
80 } \
81 constexpr bool True(type key) noexcept { \
82 using T = std::underlying_type_t<type>; \
83 return static_cast<T>(key) != 0; \
84 } \
85 constexpr bool False(type key) noexcept { \
86 using T = std::underlying_type_t<type>; \
87 return static_cast<T>(key) == 0; \
88 }
89
58namespace Common { 90namespace Common {
59 91
60constexpr u32 MakeMagic(char a, char b, char c, char d) { 92constexpr u32 MakeMagic(char a, char b, char c, char d) {