summaryrefslogtreecommitdiff
path: root/src/common/utils2.hpp
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2012-12-20 18:32:32 -0800
committerBen Longbons <b.r.longbons@gmail.com>2012-12-24 10:02:19 -0800
commit2b092c150e1226decc48160316070fc44d5fbba0 (patch)
tree48456d14896059fd223401aa15d4e29010a81436 /src/common/utils2.hpp
parentb52127bcbf817ff8285b36d22198b275327e16bb (diff)
downloadtmwa-2b092c150e1226decc48160316070fc44d5fbba0.tar.gz
tmwa-2b092c150e1226decc48160316070fc44d5fbba0.tar.bz2
tmwa-2b092c150e1226decc48160316070fc44d5fbba0.tar.xz
tmwa-2b092c150e1226decc48160316070fc44d5fbba0.zip
Enumify option, opt1, opt2, and opt3
Diffstat (limited to 'src/common/utils2.hpp')
-rw-r--r--src/common/utils2.hpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/common/utils2.hpp b/src/common/utils2.hpp
index c92fdae..326b12f 100644
--- a/src/common/utils2.hpp
+++ b/src/common/utils2.hpp
@@ -93,6 +93,46 @@ struct underlying_type
>::type type;
};
+#define ENUM_BITWISE_OPERATORS(E) \
+inline \
+E operator & (E l, E r) \
+{ \
+ typedef typename underlying_type<E>::type U;\
+ return E(U(l) & U(r)); \
+} \
+inline \
+E operator | (E l, E r) \
+{ \
+ typedef typename underlying_type<E>::type U;\
+ return E(U(l) | U(r)); \
+} \
+inline \
+E operator ^ (E l, E r) \
+{ \
+ typedef typename underlying_type<E>::type U;\
+ return E(U(l) ^ U(r)); \
+} \
+inline \
+E& operator &= (E& l, E r) \
+{ \
+ return l = l & r; \
+} \
+inline \
+E& operator |= (E& l, E r) \
+{ \
+ return l = l | r; \
+} \
+inline \
+E& operator ^= (E& l, E r) \
+{ \
+ return l = l ^ r; \
+} \
+inline \
+E operator ~ (E r) \
+{ \
+ return E(-1) ^ r; \
+}
+
template<class E>
class EnumValueIterator
{