Boost logo

Boost :

From: Boost Rookie (boostrookie_at_[hidden])
Date: 2004-09-27 04:00:13

Boost Rookie <boostrookie <at>> writes:
> I should specify something called Block/BlockInputIterator as
> a template parameter? I do not know what that is.

Playing around a little more made me realize that the following is ok:
  unsigned char data[5] = {211,14,97,42,31};
  boost::dynamic_bitset<unsigned char> bitbuf(data,&data[5]);

So, unsigned char specifies a Block and the unsigned char* is the
BlockInputIterator - alright. It wasn't that obvious for me as a newbie...

> After construction I do not see how to extract the bits!? Is it only possible
> to extract one bit at a time?!?!?

I have not find a way around this yet :-( To make myself clear, I'd like to
extract a range of bits, preferably by specifing the start bit position and the
number of bits to extract. I can see that there is a to_block_range but it just
extracts the complete bitset.

Now, another issue has surfaced. When iterating the bitset I see that the bits
are stored in a "weird" format (at least it is weird to me)?!

  for (int i=0; i<5*8; ++i)
    bool bit_i = bitbuf[i];
    std::cout << bit_i;

Instead of the expected sequence:

the loop prints:

I.e. each byte has its bits in the reversed order! As a newbie it is not
obvious to me why this is so... And the confusion is total after this:

  std::cout << bitbuf;

which decides to print the sequence:

Please help me figure the rationale behind this out!

Boost list run by bdawes at, gregod at, cpdaniel at, john at