mirror of https://github.com/libAthena/athena.git
Use constexpr for evaluating bitwise enums
This commit is contained in:
parent
c4db28821e
commit
cf3dfcddff
|
@ -77,29 +77,29 @@ typedef struct stat64 stat64_t;
|
||||||
|
|
||||||
#ifndef ENABLE_BITWISE_ENUM
|
#ifndef ENABLE_BITWISE_ENUM
|
||||||
#define ENABLE_BITWISE_ENUM(type)\
|
#define ENABLE_BITWISE_ENUM(type)\
|
||||||
inline type operator|(type a, type b)\
|
constexpr type operator|(type a, type b)\
|
||||||
{\
|
{\
|
||||||
using T = std::underlying_type_t<type>;\
|
using T = std::underlying_type_t<type>;\
|
||||||
return type(static_cast<T>(a) | static_cast<T>(b));\
|
return type(static_cast<T>(a) | static_cast<T>(b));\
|
||||||
}\
|
}\
|
||||||
inline type operator&(type a, type b)\
|
constexpr type operator&(type a, type b)\
|
||||||
{\
|
{\
|
||||||
using T = std::underlying_type_t<type>;\
|
using T = std::underlying_type_t<type>;\
|
||||||
return type(static_cast<T>(a) & static_cast<T>(b));\
|
return type(static_cast<T>(a) & static_cast<T>(b));\
|
||||||
}\
|
}\
|
||||||
inline type& operator|=(type& a, const type& b)\
|
constexpr type& operator|=(type& a, const type& b)\
|
||||||
{\
|
{\
|
||||||
using T = std::underlying_type_t<type>;\
|
using T = std::underlying_type_t<type>;\
|
||||||
a = type(static_cast<T>(a) | static_cast<T>(b));\
|
a = type(static_cast<T>(a) | static_cast<T>(b));\
|
||||||
return a;\
|
return a;\
|
||||||
}\
|
}\
|
||||||
inline type& operator&=(type& a, const type& b)\
|
constexpr type& operator&=(type& a, const type& b)\
|
||||||
{\
|
{\
|
||||||
using T = std::underlying_type_t<type>;\
|
using T = std::underlying_type_t<type>;\
|
||||||
a = type(static_cast<T>(a) & static_cast<T>(b));\
|
a = type(static_cast<T>(a) & static_cast<T>(b));\
|
||||||
return a;\
|
return a;\
|
||||||
}\
|
}\
|
||||||
inline type operator~(const type& key)\
|
constexpr type operator~(const type& key)\
|
||||||
{\
|
{\
|
||||||
using T = std::underlying_type_t<type>;\
|
using T = std::underlying_type_t<type>;\
|
||||||
return type(~static_cast<T>(key));\
|
return type(~static_cast<T>(key));\
|
||||||
|
|
Loading…
Reference in New Issue