52#define JUCE_DECLARE_SCOPED_ENUM_BITWISE_OPERATORS(EnumType) \
53 static_assert (std::is_enum_v<EnumType>, \
54 "JUCE_DECLARE_SCOPED_ENUM_BITWISE_OPERATORS " \
55 "should only be used with enum types"); \
56 constexpr auto operator& (EnumType a, EnumType b) \
58 using base_type = std::underlying_type<EnumType>::type; \
59 return static_cast<EnumType> (base_type (a) & base_type (b)); \
61 constexpr auto operator| (EnumType a, EnumType b) \
63 using base_type = std::underlying_type<EnumType>::type; \
64 return static_cast<EnumType> (base_type (a) | base_type (b)); \
66 constexpr auto operator~ (EnumType a) \
68 using base_type = std::underlying_type<EnumType>::type; \
69 return static_cast<EnumType> (~base_type (a)); \
71 constexpr auto& operator|= (EnumType& a, EnumType b) \
76 constexpr auto& operator&= (EnumType& a, EnumType b) \
86template <
typename EnumType, std::enable_if_t<std::is_enum_v<EnumType>,
int> = 0>
87constexpr bool hasBitValueSet (EnumType enumValue, EnumType valueToLookFor)
noexcept
89 return (enumValue & valueToLookFor) != EnumType{};
92template <
typename EnumType, std::enable_if_t<std::is_enum_v<EnumType>,
int> = 0>
93constexpr EnumType withBitValueSet (EnumType enumValue, EnumType valueToAdd)
noexcept
95 return enumValue | valueToAdd;
98template <
typename EnumType, std::enable_if_t<std::is_enum_v<EnumType>,
int> = 0>
99constexpr EnumType withBitValueCleared (EnumType enumValue, EnumType valueToRemove)
noexcept
101 return enumValue & ~valueToRemove;