Boost logo

Boost :

From: Terence Wilson (tez_at_[hidden])
Date: 2004-07-15 11:54:16


I have an unsigned char array which I would like to represent as an array of
bits in order to perform bit shift operations. My code is as follows:
 
// rotate bits as one large bitset

typedef unsigned char octet;
void Normalize(boost::shared_array<octet> RawHash, int RawHashLength)
{
        int ShiftLength=7;

        boost::dynamic_bitset<octet> HashBits;
        for (int i=0; i<RawHashLength; ++i)
        {
                HashBits.append(RawHash[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?

2) I get a compiler warning, it doesn't seem to like me using unsigned char.
I am using Visual Studio 2003-

c:\PROJECTS\vcpp\Libs\Boost\boost_1_31_0\boost\dynamic_bitset.hpp(655) :
warning C4267: 'initializing' : conversion from 'size_t' to 'const
boost::dynamic_bitset<Block>::block_type', possible loss of data
        with
        [
            Block=octet
        ]
        c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\xmemory(115) : while compiling class-template member
function 'boost::dynamic_bitset<Block>
&boost::dynamic_bitset<Block>::operator
<<=(boost::dynamic_bitset<Block>::size_type)'
        with
        [
            Block=octet
        ]
        c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\xmemory(156) : while compiling class-template member
function 'boost::dynamic_bitset<Block>::dynamic_bitset(const Allocator &)'
        with
        [
            Block=octet,
            Allocator=std::allocator<octet>
        ]
        c:\PROJECTS\vcpp\PasswordGenerator\Normalizer.cpp(46) : see
reference to class template instantiation 'boost::dynamic_bitset<Block>'
being compiled
        with
        [
            Block=octet
        ]
c:\PROJECTS\vcpp\Libs\Boost\boost_1_31_0\boost\dynamic_bitset.hpp(658) :
warning C4267: '=' : conversion from 'size_t' to 'octet', possible loss of
data
c:\PROJECTS\vcpp\Libs\Boost\boost_1_31_0\boost\dynamic_bitset.hpp(660) :
warning C4267: '=' : conversion from 'size_t' to 'octet', possible loss of
data
c:\PROJECTS\vcpp\Libs\Boost\boost_1_31_0\boost\detail\dynamic_bitset.hpp(88)
: warning C4267: 'return' : conversion from 'size_t' to 'octet', possible
loss of data
 
c:\PROJECTS\vcpp\Libs\Boost\boost_1_31_0\boost\detail\dynamic_bitset.hpp(88)
: while compiling class-template member function 'octet
boost::detail::dynamic_bitset_base<Block,Allocator>::mask1(boost::detail::dy
namic_bitset_base<Block,Allocator>::size_type)'
        with
        [
            Block=octet,
            Allocator=std::allocator<octet>
        ]
 
c:\PROJECTS\vcpp\Libs\Boost\boost_1_31_0\boost\dynamic_bitset.hpp(76) : see
reference to class template instantiation
'boost::detail::dynamic_bitset_base<Block,Allocator>' being compiled
        with
        [
            Block=octet,
            Allocator=std::allocator<octet>
        ]


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk