summaryrefslogtreecommitdiff
path: root/src/flag_set.hpp
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2016-06-20 22:49:05 +0200
committerBardur Arantsson <bardur@scientician.net>2016-06-20 22:49:05 +0200
commit59b5314b6b7880cfda73f34aed03a700fd523017 (patch)
tree4b5255289c8216f2d7dcfac2824045e5c0acdc45 /src/flag_set.hpp
parentfa5083020d4cc4d6d7471b461c430d40ed36c02e (diff)
Rework RF{4,5,6}_* monster spell flags to flag_set<>
Diffstat (limited to 'src/flag_set.hpp')
-rw-r--r--src/flag_set.hpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/flag_set.hpp b/src/flag_set.hpp
index 2e5d46ea..b4bdc92f 100644
--- a/src/flag_set.hpp
+++ b/src/flag_set.hpp
@@ -16,6 +16,9 @@ private:
std::uint32_t m_data[tiers];
public:
+ static constexpr const std::size_t nbits = tiers * 32;
+
+public:
constexpr flag_set()
: m_data { 0 }
@@ -81,6 +84,12 @@ public:
return !empty();
}
+ constexpr bool bit(std::size_t i) const
+ {
+ assert(i < nbits);
+ return (m_data[i / 32] & (1UL << (i % 32)));
+ }
+
flag_set &operator |= (flag_set const &other)
{
for (std::size_t i = 0; i < tiers; i++)