From: Gennaro Prota (gennaro_prota_at_[hidden])
Date: 2004-07-20 03:44:40
Sorry for the very late reply.
On Thu, 15 Jul 2004 09:54:16 -0700, "Terence Wilson" <tez_at_[hidden]>
>I have an unsigned char array which I would like to represent as an array of
>bits in order to perform bit shift operations.
One of the dynamic_bitset constructors takes two input iterators.
> My code is as follows:
>// rotate bits as one large bitset
>typedef unsigned char octet;
Please, note that the name "octet" is unadvisable, as unsigned char
may have *more* than 8 bits (but not less).
>void Normalize(boost::shared_array<octet> RawHash, int RawHashLength)
> int ShiftLength=7;
> boost::dynamic_bitset<octet> HashBits;
> for (int i=0; i<RawHashLength; ++i)
> boost::dynamic_bitset<octet> ShiftedBits=HashBits << ShiftLength;
>A couple of issues:
>1) How do I get bits out as unsigned chars after the shift operation?
There's a to_block_range function. But, please, check the shared_array
documentation. BTW, if possible for your scenario, it would be
preferable to limit conversions from/to arrays to one direction (for
instance, only from dynamic_bitset<> to an array) or to avoid them at
>2) I get a compiler warning, it doesn't seem to like me using unsigned char.
>I am using Visual Studio 2003-
Does the CVS version warn too?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk