I am looking for an off-the-shelf dynamic bit vector in C or C++ that I can use. Unfortunately for various reasons I cannot use the BoosT libraries at the moment. std:bitvector looks promising but it is templated so I cannot set the length of the bit vector dynamically. Can anyone advise? Thanks!
You don't have to put a dependency onto all of boost and its installation process just to use dynamic_bitset. If the class suits your purposes, copy the source files for it specifically into your project tree and put it in a separate namespace called "boostcopy" (or something like that).
On a similar note, I made my own resizable array class modeled after dynamic_bitset called "Nstate", which you can template to an arbitrary radix and still get tight packing. Perhaps of interest:
http://hostilefork.com/nstate/
I have never used vector<bool> (See Scott Meyers' Effective STL item 18) but it might be just what you are looking for.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With