mirror of
https://github.com/libAthena/athena.git
synced 2025-07-03 03:36:04 +00:00
Added handy bitwise enum enabler macro
This commit is contained in:
parent
18e94dbc54
commit
cdacc014f3
@ -69,6 +69,35 @@ typedef struct stat64 stat64_t;
|
|||||||
#define ROUND_UP_32(val) (((val) + 31) & ~31)
|
#define ROUND_UP_32(val) (((val) + 31) & ~31)
|
||||||
#define ROUND_UP_16(val) (((val) + 15) & ~15)
|
#define ROUND_UP_16(val) (((val) + 15) & ~15)
|
||||||
|
|
||||||
|
#define ENABLE_BITWISE_ENUM(type)\
|
||||||
|
inline type operator|(type a, type b)\
|
||||||
|
{\
|
||||||
|
using T = std::underlying_type_t<type>;\
|
||||||
|
return type(static_cast<T>(a) | static_cast<T>(b));\
|
||||||
|
}\
|
||||||
|
inline type operator&(type a, type b)\
|
||||||
|
{\
|
||||||
|
using T = std::underlying_type_t<type>;\
|
||||||
|
return type(static_cast<T>(a) & static_cast<T>(b));\
|
||||||
|
}\
|
||||||
|
inline type& operator|=(type& a, const type& b)\
|
||||||
|
{\
|
||||||
|
using T = std::underlying_type_t<type>;\
|
||||||
|
a = type(static_cast<T>(a) | static_cast<T>(b));\
|
||||||
|
return a;\
|
||||||
|
}\
|
||||||
|
inline type& operator&=(type& a, const type& b)\
|
||||||
|
{\
|
||||||
|
using T = std::underlying_type_t<type>;\
|
||||||
|
a = type(static_cast<T>(a) & static_cast<T>(b));\
|
||||||
|
return a;\
|
||||||
|
}\
|
||||||
|
inline type operator~(const type& key)\
|
||||||
|
{\
|
||||||
|
using T = std::underlying_type_t<type>;\
|
||||||
|
return type(~static_cast<T>(key));\
|
||||||
|
}
|
||||||
|
|
||||||
namespace Athena
|
namespace Athena
|
||||||
{
|
{
|
||||||
namespace error
|
namespace error
|
||||||
|
Loading…
x
Reference in New Issue
Block a user