old-DasOS/prototypes/include/enums.hpp

19 lines
619 B
C++
Raw Normal View History

2016-06-26 12:36:32 +00:00
#pragma once
#define ENUM_CLASS_OPERATORS(type) static inline type operator | (type lhs, type rhs) { \
return static_cast<type>(static_cast<uint32_t>(lhs) | static_cast<uint32_t>(rhs)); \
} \
static inline type operator & (type lhs, type rhs) { \
return static_cast<type>(static_cast<uint32_t>(lhs) & static_cast<uint32_t>(rhs)); \
} \
static inline bool operator * (type lhs, type rhs) { \
return (static_cast<uint32_t>(lhs) & static_cast<uint32_t>(rhs)) != 0; \
} \
static inline type & operator |=(type & lhs, type rhs) { \
reinterpret_cast<uint32_t&>(lhs) |= static_cast<uint32_t>(rhs); \
return lhs; \
}