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 92
92
using ::llvm::BitmaskEnumDetail::operator ^=; \
93
93
using ::llvm::BitmaskEnumDetail::operator <<=; \
94
94
using ::llvm::BitmaskEnumDetail::operator >>=; \
95
+ using ::llvm::BitmaskEnumDetail::operator !; \
95
96
/* Force a semicolon at the end of this macro. */ \
96
97
using ::llvm::BitmaskEnumDetail::any
97
98
@@ -141,6 +142,11 @@ constexpr unsigned bitWidth(uint64_t Value) {
141
142
return Value ? 1 + bitWidth (Value >> 1 ) : 0 ;
142
143
}
143
144
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
+
144
150
template <typename E, typename = std::enable_if_t <is_bitmask_enum<E>::value>>
145
151
constexpr bool any (E Val) {
146
152
return Val != static_cast <E>(0 );
Original file line number Diff line number Diff line change @@ -176,6 +176,17 @@ TEST(BitmaskEnumTest, BitwiseNot) {
176
176
EXPECT_EQ (15 , ~V0);
177
177
}
178
178
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
+
179
190
enum class FlagsClass {
180
191
F0 = 0 ,
181
192
F1 = 1 ,
You can’t perform that action at this time.
0 commit comments