summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Morph2021-09-13 16:01:20 -0400
committerGravatar Morph2021-09-13 16:01:20 -0400
commit3512cae62368d6897f9e6c8aced785e0ce89e156 (patch)
tree4791c8b413cc98e9c025e301e5c9897581795360
parentMerge pull request #7000 from Morph1984/create-dir-comment (diff)
downloadyuzu-3512cae62368d6897f9e6c8aced785e0ce89e156.tar.gz
yuzu-3512cae62368d6897f9e6c8aced785e0ce89e156.tar.xz
yuzu-3512cae62368d6897f9e6c8aced785e0ce89e156.zip
common_funcs: Add enum flag bitwise shift operator overloads
This adds bitwise shift operator overloads (<<, >>, <<=, >>=) in the macro DECLARE_ENUM_FLAG_OPERATORS(type)
-rw-r--r--src/common/common_funcs.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/common/common_funcs.h b/src/common/common_funcs.h
index 1e74d6930..4c1e29de6 100644
--- a/src/common/common_funcs.h
+++ b/src/common/common_funcs.h
@@ -61,6 +61,14 @@ __declspec(dllimport) void __stdcall DebugBreak(void);
61 using T = std::underlying_type_t<type>; \ 61 using T = std::underlying_type_t<type>; \
62 return static_cast<type>(static_cast<T>(a) ^ static_cast<T>(b)); \ 62 return static_cast<type>(static_cast<T>(a) ^ static_cast<T>(b)); \
63 } \ 63 } \
64 [[nodiscard]] constexpr type operator<<(type a, type b) noexcept { \
65 using T = std::underlying_type_t<type>; \
66 return static_cast<type>(static_cast<T>(a) << static_cast<T>(b)); \
67 } \
68 [[nodiscard]] constexpr type operator>>(type a, type b) noexcept { \
69 using T = std::underlying_type_t<type>; \
70 return static_cast<type>(static_cast<T>(a) >> static_cast<T>(b)); \
71 } \
64 constexpr type& operator|=(type& a, type b) noexcept { \ 72 constexpr type& operator|=(type& a, type b) noexcept { \
65 a = a | b; \ 73 a = a | b; \
66 return a; \ 74 return a; \
@@ -73,6 +81,14 @@ __declspec(dllimport) void __stdcall DebugBreak(void);
73 a = a ^ b; \ 81 a = a ^ b; \
74 return a; \ 82 return a; \
75 } \ 83 } \
84 constexpr type& operator<<=(type& a, type b) noexcept { \
85 a = a << b; \
86 return a; \
87 } \
88 constexpr type& operator>>=(type& a, type b) noexcept { \
89 a = a >> b; \
90 return a; \
91 } \
76 [[nodiscard]] constexpr type operator~(type key) noexcept { \ 92 [[nodiscard]] constexpr type operator~(type key) noexcept { \
77 using T = std::underlying_type_t<type>; \ 93 using T = std::underlying_type_t<type>; \
78 return static_cast<type>(~static_cast<T>(key)); \ 94 return static_cast<type>(~static_cast<T>(key)); \