ftl::Flags: Offer set and clear APIs for convenience and readability
Bug: None
Test: None
Change-Id: Idbe075dd919fd71bdcb7b1fb4a182c44d243b378
diff --git a/include/ftl/Flags.h b/include/ftl/Flags.h
index 932af2d..708eaf5 100644
--- a/include/ftl/Flags.h
+++ b/include/ftl/Flags.h
@@ -120,10 +120,10 @@
}
/* Tests whether any of the given flags are set */
- bool any(Flags<F> f) { return (mFlags & f.mFlags) != 0; }
+ bool any(Flags<F> f) const { return (mFlags & f.mFlags) != 0; }
/* Tests whether all of the given flags are set */
- bool all(Flags<F> f) { return (mFlags & f.mFlags) == f.mFlags; }
+ bool all(Flags<F> f) const { return (mFlags & f.mFlags) == f.mFlags; }
Flags<F> operator|(Flags<F> rhs) const { return static_cast<F>(mFlags | rhs.mFlags); }
Flags<F>& operator|=(Flags<F> rhs) {
@@ -153,6 +153,10 @@
return *this;
}
+ inline Flags<F>& clear(Flags<F> f = static_cast<F>(~static_cast<U>(0))) {
+ return *this &= ~f;
+ }
+
Iterator begin() const { return Iterator(*this); }
Iterator end() const { return Iterator(); }