Hello sirs, you might know that Boost has a dynamic_bitset
class, but did you know that GCC also has it? Turns out it's included in the tr2 folder. You can simply include <tr2/dynamic_bitset>
, and use it as tr2::dynamic_bitset
.
The implementation seems identical to Boost's dynamic bitset, so you can read the full docs here. You can view the source here.
Comparing to std::bitset, here are some notable things I saw: - They include more set operations, such as set difference, and checking if a bitset is a subset of another bitset. - They include lexicographical comparisons between bitsets. - You can append single bits, as well as whole blocks (i.e. integers) - You can also resize it like a vector. - Find first and find next are also supported, without weird function names like std::bitset. Unfortunately, there's still no find previous :(
Of course, it also has all the std::bitset functionality. I'm not sure how good the performance is for this, so you can let me know in the comments.