This commit is contained in:
ZY4N
2024-12-22 16:58:40 +01:00
parent 2704814de2
commit db8db8f9d7
161 changed files with 17102 additions and 0 deletions

View 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; \
}