summaryrefslogtreecommitdiffhomepage
path: root/compat
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2018-12-29 13:31:00 +0100
committerStanislaw Halik <sthalik@misaki.pl>2019-01-16 07:48:19 +0100
commit9fd246a411e9faaf49c6b18c020fde351b9412a6 (patch)
treeba55042406bce9d468ac6fee4da7df5115f73b0f /compat
parent8e865212848752668d67af91f227737abe9044a3 (diff)
compat/enum-operators: add assign operators
Diffstat (limited to 'compat')
-rw-r--r--compat/enum-operators.hpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/compat/enum-operators.hpp b/compat/enum-operators.hpp
index e7300239..188a081d 100644
--- a/compat/enum-operators.hpp
+++ b/compat/enum-operators.hpp
@@ -20,10 +20,26 @@
return type(op t_((x))); \
} // end
+#define OTR_FLAGS_ASSIGN_OP(type, op) \
+ inline type& operator op ## = (type& lhs, type rhs) \
+ { \
+ using t_ = std::underlying_type_t<decltype(rhs)>; \
+ lhs = type(t_((lhs)) op t_((rhs))); \
+ return lhs; \
+ } //end
+
+#define OTR_FLAGS_DELETE_SHIFT_ASSIGN(type, op) \
+ type operator op ## = (type& lhs, type rhs) = delete //end
+
#define DEFINE_ENUM_OPERATORS(type) \
OTR_FLAGS_OP2(type, |) \
OTR_FLAGS_OP2(type, &) \
OTR_FLAGS_OP2(type, ^) \
OTR_FLAGS_OP1(type, ~) \
- OTR_FLAGS_SHIFT(type, <<); \
- OTR_FLAGS_SHIFT(type, >>) // end
+ OTR_FLAGS_DELETE_SHIFT(type, <<); \
+ OTR_FLAGS_DELETE_SHIFT(type, >>); \
+ OTR_FLAGS_ASSIGN_OP(type, |) \
+ OTR_FLAGS_ASSIGN_OP(type, &) \
+ OTR_FLAGS_ASSIGN_OP(type, ^) \
+ OTR_FLAGS_DELETE_SHIFT_ASSIGN(type, <<); \
+ OTR_FLAGS_DELETE_SHIFT_ASSIGN(type, >>) // end