mirror of
https://github.com/AxioDL/kabufuda.git
synced 2025-05-13 10:51:20 +00:00
Use constexpr for evaluating bitwise enums
This commit is contained in:
parent
99069bd069
commit
d242e2deb6
@ -36,29 +36,29 @@
|
|||||||
|
|
||||||
#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…
x
Reference in New Issue
Block a user