dynamic_bitset
is implemented as a template class, so you can just include the header file to use it.
dynamic_bitset
does not depend any library except for STL.
- C++11 compiler
#include "dynamic_bitset.hh"
// init with 13 bits. fill bitfield with value `42`
dynamic_bitset db(13, 42);
// init with 0bits
dynamic_bitset db;
// resize to 12 bits
db.resize(12);
// resize does not initialize extended memory region.
// Use `reset()` to clear all bitfields.
db.reset();
// set 3rd bit true
db.set(3);
// get 5th bit state
std::cout << db[5] << "\n";
// print bitfield
std::cout << db.to_string() << "\n";
// set all bits with true or false
db.setall(true);
dynamic_bitset
has similar functions defined in std::bitset
and std::vector
.
dynamic_bitset
is not compatible with boost::dynamic_bitset
- [ ] Implement more features.
- [ ] Validate endianness.
- [ ] Write more tests.
- Feature-complete dynamic_bitset in C++17 https://github.com/pinam45/dynamic_bitset
dynamic_bitset is licensed under MIT license.
- acutest : For unit test. MIT license.