fixes
This commit is contained in:
57
include/util/enum_operators.hpp
Normal file
57
include/util/enum_operators.hpp
Normal file
@@ -0,0 +1,57 @@
|
||||
#pragma once
|
||||
|
||||
#define DEFINE_ENUM_FLAG_OPERATORS(ENUM_TYPE) \
|
||||
[[nodiscard]] constexpr ENUM_TYPE operator|( \
|
||||
const ENUM_TYPE lhs, const ENUM_TYPE rhs \
|
||||
) { \
|
||||
return static_cast<ENUM_TYPE>( \
|
||||
static_cast<std::underlying_type_t<ENUM_TYPE>>(lhs) | \
|
||||
static_cast<std::underlying_type_t<ENUM_TYPE>>(rhs) \
|
||||
); \
|
||||
} \
|
||||
\
|
||||
[[nodiscard]] constexpr ENUM_TYPE operator&( \
|
||||
const ENUM_TYPE lhs, const ENUM_TYPE rhs \
|
||||
) { \
|
||||
return static_cast<ENUM_TYPE>( \
|
||||
static_cast<std::underlying_type_t<ENUM_TYPE>>(lhs) & \
|
||||
static_cast<std::underlying_type_t<ENUM_TYPE>>(rhs) \
|
||||
); \
|
||||
} \
|
||||
\
|
||||
[[nodiscard]] constexpr ENUM_TYPE operator^( \
|
||||
const ENUM_TYPE lhs, const ENUM_TYPE rhs \
|
||||
) { \
|
||||
return static_cast<ENUM_TYPE>( \
|
||||
static_cast<std::underlying_type_t<ENUM_TYPE>>(lhs) ^ \
|
||||
static_cast<std::underlying_type_t<ENUM_TYPE>>(rhs) \
|
||||
); \
|
||||
} \
|
||||
\
|
||||
[[nodiscard]] constexpr ENUM_TYPE operator~(const ENUM_TYPE a) \
|
||||
{ \
|
||||
return static_cast<ENUM_TYPE>( \
|
||||
~static_cast<std::underlying_type_t<ENUM_TYPE>>(a) \
|
||||
); \
|
||||
} \
|
||||
\
|
||||
constexpr ENUM_TYPE& operator|=( \
|
||||
ENUM_TYPE& lhs, \
|
||||
const ENUM_TYPE rhs \
|
||||
) { \
|
||||
return lhs = lhs | rhs; \
|
||||
} \
|
||||
\
|
||||
constexpr ENUM_TYPE& operator&=( \
|
||||
ENUM_TYPE& lhs, \
|
||||
const ENUM_TYPE rhs \
|
||||
) { \
|
||||
return lhs = lhs & rhs; \
|
||||
} \
|
||||
\
|
||||
constexpr ENUM_TYPE& operator^=( \
|
||||
ENUM_TYPE& lhs, \
|
||||
const ENUM_TYPE rhs \
|
||||
) { \
|
||||
return lhs = lhs ^ rhs; \
|
||||
}
|
||||
Reference in New Issue
Block a user