File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change 9292 using ::llvm::BitmaskEnumDetail::operator ^=; \
9393 using ::llvm::BitmaskEnumDetail::operator <<=; \
9494 using ::llvm::BitmaskEnumDetail::operator >>=; \
95+ using ::llvm::BitmaskEnumDetail::operator !; \
9596 /* Force a semicolon at the end of this macro. */ \
9697 using ::llvm::BitmaskEnumDetail::any
9798
@@ -141,6 +142,11 @@ constexpr unsigned bitWidth(uint64_t Value) {
141142 return Value ? 1 + bitWidth (Value >> 1 ) : 0 ;
142143}
143144
145+ template <typename E, typename = std::enable_if_t <is_bitmask_enum<E>::value>>
146+ constexpr bool operator !(E Val) {
147+ return Val == static_cast <E>(0 );
148+ }
149+
144150template <typename E, typename = std::enable_if_t <is_bitmask_enum<E>::value>>
145151constexpr bool any (E Val) {
146152 return Val != static_cast <E>(0 );
Original file line number Diff line number Diff line change @@ -176,6 +176,17 @@ TEST(BitmaskEnumTest, BitwiseNot) {
176176 EXPECT_EQ (15 , ~V0);
177177}
178178
179+ TEST (BitmaskEnumTest, BooleanNot) {
180+ bool b0 = !F0;
181+ EXPECT_TRUE (b0);
182+
183+ bool b1 = !(F1 & F2);
184+ EXPECT_TRUE (b1);
185+
186+ bool b2 = !(F2 | F4);
187+ EXPECT_FALSE (b2);
188+ }
189+
179190enum class FlagsClass {
180191 F0 = 0 ,
181192 F1 = 1 ,
You can’t perform that action at this time.
0 commit comments