#pragma once #include "CoreTypes.h" #include "TypeTraits/TypeTraits.h" NAMESPACE_REDCRAFT_BEGIN NAMESPACE_MODULE_BEGIN(Redcraft) NAMESPACE_MODULE_BEGIN(Utility) #define ENABLE_ENUM_CLASS_BITWISE_OPERATIONS(Enum) \ NODISCARD FORCEINLINE constexpr Enum operator| (Enum LHS, Enum RHS) { return static_cast(static_cast>(LHS) | static_cast>(RHS)); } \ NODISCARD FORCEINLINE constexpr Enum operator& (Enum LHS, Enum RHS) { return static_cast(static_cast>(LHS) & static_cast>(RHS)); } \ NODISCARD FORCEINLINE constexpr Enum operator^ (Enum LHS, Enum RHS) { return static_cast(static_cast>(LHS) ^ static_cast>(RHS)); } \ FORCEINLINE constexpr Enum& operator|=(Enum& LHS, Enum RHS) { LHS = LHS | RHS; return LHS; } \ FORCEINLINE constexpr Enum& operator&=(Enum& LHS, Enum RHS) { LHS = LHS & RHS; return LHS; } \ FORCEINLINE constexpr Enum& operator^=(Enum& LHS, Enum RHS) { LHS = LHS ^ RHS; return LHS; } \ NODISCARD FORCEINLINE constexpr bool operator! (Enum E ) { return !static_cast>(E); } \ NODISCARD FORCEINLINE constexpr Enum operator~ (Enum E ) { return static_cast(~static_cast>(E)); } #define FRIEND_ENUM_CLASS_BITWISE_OPERATIONS(Enum) \ friend constexpr Enum operator| (Enum , Enum); \ friend constexpr Enum operator& (Enum , Enum); \ friend constexpr Enum operator^ (Enum , Enum); \ friend constexpr Enum& operator|=(Enum&, Enum); \ friend constexpr Enum& operator&=(Enum&, Enum); \ friend constexpr Enum& operator^=(Enum&, Enum); \ friend constexpr bool operator! (Enum ); \ friend constexpr Enum operator~ (Enum ); NAMESPACE_MODULE_END(Utility) NAMESPACE_MODULE_END(Redcraft) NAMESPACE_REDCRAFT_END