Perform count on a range of bits in boost dynamic_bitset

224 Views Asked by At

I'm using boost::dynamic_bitset to store a large number of bits. I need to count the number of bits set but only on a part of the bitset at a time. The count function which boost provides doesn't take a range as parameter. I don't want to modify my original bitset. One option is to use >> operator, keep only the bits I need and then use the count function on that duplicate bitset but there is an overhead of duplicate bitset creation.

Can anyone suggest any other method to achieve this? Please note I'm focusing on count method as it's optimized for performance.

0

There are 0 best solutions below