diff options
| author | 2022-02-07 02:54:39 -0800 | |
|---|---|---|
| committer | 2022-02-11 08:22:13 -0800 | |
| commit | f0a3d814ee6e01b0dd398a9df4af462eb91d0b59 (patch) | |
| tree | 63bb5364af89c1be886672084eaba052a34ed98b | |
| parent | f24d8d6d71a865b4e6409420c42356c8bfd1bc87 (diff) | |
ftl::Flags: Offer set and clear APIs for convenience and readability
Bug: None
Test: None
Change-Id: Idbe075dd919fd71bdcb7b1fb4a182c44d243b378
| -rw-r--r-- | include/ftl/Flags.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/include/ftl/Flags.h b/include/ftl/Flags.h index 932af2d9f9..708eaf5dde 100644 --- a/include/ftl/Flags.h +++ b/include/ftl/Flags.h @@ -120,10 +120,10 @@ public: } /* 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 @@ public: 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(); } |