How to query if any bit in a range is set in C ++ std :: bitset?

I am looking for a C ++ bit set implementation that can answer if a bit is specified in a range. std :: bitset , vector and boost :: dynamic_bitset give access to individual bits that I can iterate over, but this is not the most efficient way to request a range of bits for a request if any bit is set - I don’t even need to know which one.

bitset b;
if(b.any(33, 199))
{
    // ...
}

Is there a library that provides this? I would like to run some tests against other implementations (including, perhaps, I will have to write), but I can not find any possibilities for implementing this function.

+4
source share
1

++ 11 bitset any(), , , b.to_ulong() , .

-1

All Articles