I was just playing around a bit(no pun intended) with std::bitset
in c++ and I ran in to a problem.
I can use OR
, AND
and EXCLUSIVE OR
just fine, but when I try to do shift operations using >>
and <<
I get an error saying
Error: no operator "<<" matches these operands
The code I have looks like this:
#include <iostream>
#include <bitset>
using namespace std;
int main()
{
bitset<8> test = 0x05;
bitset<8> test2 = 0x00;
bitset<8> lshift = test << test2;
cout<<lshift<<endl;
system("PAUSE");
return 0;
}
There is simply no such operator defined for shifting a std::bitset
by another std::bitset
. The only shifting operators are defined for arguments of type std::size_t
, see for example http://en.cppreference.com/w/cpp/utility/bitset/operator_ltltgtgt.