mirror of
https://github.com/encounter/aurora.git
synced 2025-07-04 20:26:07 +00:00
Use constexpr for evaluating bitwise enums
This commit is contained in:
parent
d770499c96
commit
4ccc8bd3c1
@ -36,29 +36,29 @@
|
||||
|
||||
#ifndef ENABLE_BITWISE_ENUM
|
||||
#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>;\
|
||||
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>;\
|
||||
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>;\
|
||||
a = type(static_cast<T>(a) | static_cast<T>(b));\
|
||||
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>;\
|
||||
a = type(static_cast<T>(a) & static_cast<T>(b));\
|
||||
return a;\
|
||||
}\
|
||||
inline type operator~(const type& key)\
|
||||
constexpr type operator~(const type& key)\
|
||||
{\
|
||||
using T = std::underlying_type_t<type>;\
|
||||
return type(~static_cast<T>(key));\
|
||||
|
Loading…
x
Reference in New Issue
Block a user