diff options
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 { |