I am trying to create a vector of bitsets in C++. For this, I have tried the attempt as shown in the code snippet below:
vector<bitset<8>> bvc;
while (true) {
bitset<8> bstemp( (long) xtemp );
if (bstemp.count == y1) {
bvc.push_back(bstemp);
}
if ( xtemp == 0) {
break;
}
xtemp = (xtemp-1) & ntemp;
}
When I try to compile the program, I get the error that reads that bvc
was not declared in the scope. It further tells that the template argument 1 and 2 are invalid. (the 1st line). Also, in the line containing bvc.push_back(bstemp)
, I am getting an error that reads invalid use of member function.
I have a feeling that you're using pre C++11.
Change this:
vector<bitset<8>> bvc;
to this:
vector<bitset<8> > bvc;
Otherwise, the >>
is parsed as the right-shift operator. This was "fixed" in C++11.