summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/flag_set.hpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/flag_set.hpp b/src/flag_set.hpp
index b4bdc92f..aa90a217 100644
--- a/src/flag_set.hpp
+++ b/src/flag_set.hpp
@@ -67,6 +67,19 @@ public:
return true;
}
+ constexpr std::size_t count() const
+ {
+ std::size_t n = 0;
+ for (std::size_t i = 0; i < nbits; i++)
+ {
+ if (bit(i))
+ {
+ n += 1;
+ }
+ }
+ return n;
+ }
+
uint32_t &operator[](std::size_t i)
{
assert(i < tiers);