diff options
Diffstat (limited to 'include/chilbert/detail')
-rw-r--r-- | include/chilbert/detail/BitVecIndex.hpp | 2 | ||||
-rw-r--r-- | include/chilbert/detail/MultiBitVec.hpp | 6 | ||||
-rw-r--r-- | include/chilbert/detail/operations.hpp | 2 |
3 files changed, 7 insertions, 3 deletions
diff --git a/include/chilbert/detail/BitVecIndex.hpp b/include/chilbert/detail/BitVecIndex.hpp index a514c21..7eb128d 100644 --- a/include/chilbert/detail/BitVecIndex.hpp +++ b/include/chilbert/detail/BitVecIndex.hpp @@ -21,7 +21,7 @@ struct BitVecIndex { explicit BitVecIndex(const size_t bits) : rack{bits / bits_per_rack} - , bit{bits - rack * bits_per_rack} + , bit{bits - (rack * bits_per_rack)} { assert(bit < bits_per_rack); } diff --git a/include/chilbert/detail/MultiBitVec.hpp b/include/chilbert/detail/MultiBitVec.hpp index bf1802c..1317d3b 100644 --- a/include/chilbert/detail/MultiBitVec.hpp +++ b/include/chilbert/detail/MultiBitVec.hpp @@ -111,7 +111,7 @@ public: /// Clear any bits in storage outside the valid range if necessary void truncate() { - if (const auto pad = num_racks() * bits_per_rack - size()) { + if (const auto pad = (num_racks() * bits_per_rack) - size()) { rack(num_racks() - 1) &= ~Rack{0} >> pad; } } @@ -334,6 +334,10 @@ public: private: using Index = detail::BitVecIndex<Derived>; + friend Derived; + + MultiBitVec() = default; + Derived* self() { return static_cast<Derived*>(this); } const Derived* self() const { return static_cast<const Derived*>(this); } }; diff --git a/include/chilbert/detail/operations.hpp b/include/chilbert/detail/operations.hpp index 5dd59db..b7aff09 100644 --- a/include/chilbert/detail/operations.hpp +++ b/include/chilbert/detail/operations.hpp @@ -110,7 +110,7 @@ pop_count(const uint64_t field) /// Return 1 + the index of the least significant 1-bit of `field`, or zero template<typename T> inline int -pop_count(const T field); +pop_count(T field); template<> inline int |