Questions tagged [boost-dynamic-bitset]

Boost.Dynamic_Bitset is a C++ library that is nearly identical to the std::bitset class, the difference being that the size of the dynamic_bitset (the number of bits) is specified at run-time during the construction of a dynamic_bitset object, whereas the size of a std::bitset is specified at compile-time through an integer template parameter.

Boost.Dynamic_Bitset is a C++ library that is nearly identical to the std::bitset class, the difference being that the size of the dynamic_bitset (the number of bits) is specified at run-time during the construction of a dynamic_bitset object, whereas the size of a std::bitset is specified at compile-time through an integer template parameter.

49 questions
13
votes
2 answers

boost::dynamic_bitset slower than std::bitset unless std::bitset is reset

I recently came across the bitset templates and would really like to use them in my current project. Reading on, I see that the std::bitset template must have a size determined at compile time. Many suggest using the boost::dynamic_bitset to…
nick
  • 319
  • 1
  • 4
  • 18
5
votes
2 answers

How to serialize boost::dynamic_bitset?

How to serialize a class with a boost::dynamic_bitset member? #include #include #include #include #include…
Michal
  • 2,078
  • 19
  • 29
4
votes
1 answer

Why do I need to call std::move on a temporary dynamic_bitset?

I'm telling a longwinded backstory here because, in addition to a direct answer, I'd like to know if my reasoning which led into this situation was correct. I have a function taking a dynamic_bitset<> argument (from Boost.dynamic_bitset). Say it…
Nick Matteo
  • 4,453
  • 1
  • 24
  • 35
4
votes
1 answer

C++ Storing a dynamic_bitset into a file

Sort of a follow up to How does one store a vector or a bitset into a file, but bit-wise? Basically I am writing a bitset as a binary file with the follow code: boost::dynamic_bitset::block_type>…
3
votes
1 answer

boost::dynamic_bitset<> fills in reverse order no matter what

I have a massive bitset representing all the bits of a 74MB file. I am using a compression algorithm to create a compressed string representation of this bitset. I need to then store that string into another dynamic bitset so that it can be…
Connor S
  • 353
  • 2
  • 12
3
votes
1 answer

Bitset as the return value of a function

I'd like to have an interface whose function returns a bitset: class IMyInterface { public: virtual std::bitset<100> GetBits() = 0; }; The problem is that I don't want to force the size of the bitset. So I think I have to use…
B Faley
  • 17,120
  • 43
  • 133
  • 223
2
votes
1 answer

Boost dynamic_bitset - put an integer value into a range of bits

I have a 7-byte/56-bit bitset that upon construction sets the first bit to one: boost::dynamic_bitset<> b(56, 1); After construction, I'd like to place an integer value (say 2019) into bits 4 through 15. I'm curious if there is a simple way…
01100110
  • 2,294
  • 3
  • 23
  • 32
2
votes
1 answer

How to iterate over all the bitstrings with one 0, two 0s, all the way down to n 0s?

I have a function to increment a bitstring as follows: void increment(boost::dynamic_bitset<> &bitset) { for (int loop = 0; loop < bitset.size(); ++loop) { if ((bitset[loop] ^= 0x1) == 0x1) { break; } …
Jim
  • 4,509
  • 16
  • 50
  • 80
2
votes
0 answers

Perform count on a range of bits in boost dynamic_bitset

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…
escapist
  • 31
  • 2
2
votes
2 answers

Reverse order of boost::dynamic_bitset

Is there a clean way to return the reverse ordering of a boost::dynamic_bitset object? For example: 01001100 becomes 00110010. The simplest solution I can think of is to convert the bitset to a string, reverse the string and convert it back to a…
opheliemac
  • 151
  • 4
2
votes
1 answer

Is boost dynamic_bitset header-only

By all initial indications, boost dynamic_bitset is header only. The documentation implies that it is header only: The class dynamic_bitset is defined in the header boost/dynamic_bitset.hpp. Also, there is a forward declaration for dynamic_bitset…
BeeOnRope
  • 60,350
  • 16
  • 207
  • 386
2
votes
1 answer

boost::dynamic_bitset inconsistent result with std::vector?

I look up the boost's implementation of the dynamic_bitset and find that they compares the underlying integer storage type to improve the operator< performance, I test the correctness with following code and get the inconsistent result. Is this a…
康桓瑋
  • 33,481
  • 5
  • 40
  • 90
2
votes
1 answer

Serialize boost::bimap with boost::dynamic_bitset as key value pair

I am interested to serialize a boost::bimap containing boost::dynamic_bitset so that I can save that and load back when needed. I have made an attempt to do that but I get many errors. The code that I have with me is as below. // Example…
AwaitedOne
  • 992
  • 3
  • 19
  • 42
2
votes
1 answer

Why is boost::dynamic_bitset a template?

I have used boost::dynamic_bitset before as boost::dynamic_bitset<>, without really thinking about why it is templated. Though I can understand why std::bitset is templated (the template type is used to specify the size of the bitset), I have now…
user2891462
  • 3,033
  • 2
  • 32
  • 60
2
votes
1 answer

How does boost::dynamic_bitset store bits

I am having a hard time understanding what boost:::dynamic_bitset, or std::vector do internally. What I eventually want to do is compose a network frame and send it via socket, but I just cannot convert them in a way that keeps the bit order I…
Marcel Boldt
  • 252
  • 2
  • 12
1
2 3 4