Files
spark/src/lib/core/EnumBitwiseOperators.h
T

16 lines
757 B
C

#pragma once
#define BITWISE_OP(enum_type, numeric_type, op) \
enum_type operator op(enum_type lhs, enum_type rhs) noexcept { \
return static_cast<enum_type>(static_cast<numeric_type>(lhs) \
op static_cast<numeric_type>(rhs)); \
}
#define BITWISE_OPS(enum_type, numeric_type) \
BITWISE_OP(enum_type, numeric_type, |) \
BITWISE_OP(enum_type, numeric_type, &) \
BITWISE_OP(enum_type, numeric_type, ^)
#define HAS_FLAG(enum_value, flag) (enum_value & flag) == flag
#define STRIP_FLAG(enum_value, flag) (enum_value | flag) ^ flag