From d3b0a3dc4654f553c714c970435865f442e4bfdc Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Tue, 18 May 2021 21:40:54 +0300 Subject: [PATCH] bs_t<>: add all_of() and none_of() Convenience functions. --- Utilities/bit_set.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Utilities/bit_set.h b/Utilities/bit_set.h index ce795e8eba..494700d0b3 100644 --- a/Utilities/bit_set.h +++ b/Utilities/bit_set.h @@ -163,6 +163,16 @@ public: m_data ^= shift(bit); return r; } + + constexpr bool all_of(bs_t arg) + { + return (m_data & arg.m_data) == arg.m_data; + } + + constexpr bool none_of(bs_t arg) + { + return (m_data & arg.m_data) == 0; + } }; // Unary '+' operator: promote plain enum value to bitset value @@ -360,6 +370,16 @@ public: bool bit_test_set(uint bit) = delete; bool bit_test_reset(uint bit) = delete; bool bit_test_invert(uint bit) = delete; + + bool all_of(bs_t arg) + { + return base::load().all_of(arg); + } + + bool none_of(bs_t arg) + { + return base::load().none_of(arg); + } }; template