1
0
Fork 0

Add: EnumBitSet function to test if All or Any enum values are set.

This allows multiple values to be tested in one operation.
pull/13413/head
Peter Nelson 2025-01-30 19:32:41 +00:00
parent 4ac45e5f87
commit 507922d43e
No known key found for this signature in database
GPG Key ID: 8EF8F0A467DF75ED
1 changed files with 20 additions and 0 deletions

View File

@ -183,6 +183,26 @@ public:
return (this->data & (1U << to_underlying(value))) != 0;
}
/**
* Test if all of the enum values are set.
* @param other BitSet of enum values to test.
* @returns true iff all of the enum values are set.
*/
inline constexpr bool All(const EnumBitSet &other) const
{
return (this->data & other.data) == other.data;
}
/**
* Test if any of the enum values are set.
* @param other BitSet of enum values to test.
* @returns true iff any of the enum values are set.
*/
inline constexpr bool Any(const EnumBitSet &other) const
{
return (this->data & other.data) != 0;
}
inline constexpr EnumBitSet operator |(const EnumBitSet &other) const
{
return EnumBitSet{static_cast<Tstorage>(this->data | other.data)};