[Boost.dynamic_bitset bug]: operators <<= and >>= interchanged?

boost_1_33_1 Dear all, I suspect that the shift operator of the dynamic_bitset are reversed. Best regards, Martin Moene ___ C:\>dynamic_bitset.exe x :11111 x <<= 1:01111 x >>= 2:11100 /* * dynamic_bitset bug: operator <<= and >>= interchanged. * * cl -GX -ID:/Libraries/boost_1_33_1/ dynamic_bitset.cpp * cl -GX -IC:/Libraries/boost_1_33_1/ dynamic_bitset.cpp * cl -GX -I%BOOST% dynamic_bitset.cpp */ #include <iostream> #include <boost/dynamic_bitset.hpp> std::ostream& operator<<( std::ostream& os, boost::dynamic_bitset<> const& bs ) { for ( boost::dynamic_bitset<>::size_type i = 0; i < bs.size(); ++i ) { os << bs[i]; } return os; } int main( int, char*[] ) { boost::dynamic_bitset<> x(5); // all 0's by default x.set(); std::cout << "x :" << x << std::endl; std::cout << "x <<= 1:" << ( x <<= 1 ) << std::endl; std::cout << "x >>= 2:" << ( x >>= 2 ) << std::endl; return EXIT_FAILURE; }

On Wed, 17 Jan 2007, Martin Moene wrote:
boost_1_33_1
Dear all,
I suspect that the shift operator of the dynamic_bitset are reversed.
They are not, the problem is that you display the bits in reversed order (least to most significant) in your operator<< . -- François Duranleau LIGUM, Université de Montréal

François Duranleau wrote:
On Wed, 17 Jan 2007, Martin Moene wrote:
boost_1_33_1
Dear all,
I suspect that the shift operator of the dynamic_bitset are reversed.
They are not, the problem is that you display the bits in reversed order (least to most significant) in your operator<< . Thanks,
I'm working on (bit-)images and am used to look at pixels from left to right. Had better better read the documentation of std::bitset and its dynamic analogue first... From the SGI documentation: bitset's interface resembles that of unsigned integers. ... In general, bit 0 is the least significant bit and bit N-1 is the most significant bit. Martin.
participants (3)
-
François Duranleau
-
Martin J. Moene
-
Martin Moene