Boost logo

Boost Users :

From: Martin Moene (m.j.moene_at_[hidden])
Date: 2007-01-17 07:28:42


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;
}


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net