diff options
author | Ben Longbons <b.r.longbons@gmail.com> | 2012-12-20 18:32:32 -0800 |
---|---|---|
committer | Ben Longbons <b.r.longbons@gmail.com> | 2012-12-24 10:02:19 -0800 |
commit | 2b092c150e1226decc48160316070fc44d5fbba0 (patch) | |
tree | 48456d14896059fd223401aa15d4e29010a81436 /src/common/utils2.hpp | |
parent | b52127bcbf817ff8285b36d22198b275327e16bb (diff) | |
download | tmwa-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.hpp | 40 |
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 { |