aboutsummaryrefslogtreecommitdiffstats
path: root/chilbert/Operations.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'chilbert/Operations.hpp')
-rw-r--r--chilbert/Operations.hpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/chilbert/Operations.hpp b/chilbert/Operations.hpp
index b2e4344..5781e6c 100644
--- a/chilbert/Operations.hpp
+++ b/chilbert/Operations.hpp
@@ -90,6 +90,24 @@ setBit(T& field, const BitsetIndex<T> index, const bool value)
/// Return 1 + the index of the least significant 1-bit of `field`, or zero
template <typename T>
+int pop_count(const T& field);
+
+template <>
+int
+pop_count<unsigned long>(const unsigned long& field)
+{
+ return __builtin_popcountl(field);
+}
+
+template <>
+int
+pop_count<unsigned long long>(const unsigned long long& field)
+{
+ return __builtin_popcountll(field);
+}
+
+/// Return 1 + the index of the least significant 1-bit of `field`, or zero
+template <typename T>
int ffs(const T field);
template <>