I am using an unsigned char vector which has some hex values.
std::vector<unsigned char> sync;
sync.push_back(0x50);
sync.push_back(0x51);
sync.push_back(0x52);
sync.push_back(0x53);
Then, using a bitset I "morph" the sync[3] to an 8 bit representation.This is because I need to corrupt/toggle any random bit in it.
srand(time(NULL));
int bitsetIndex= random()%8;
std::bitset<8> manipulator(v[3]); //v is the vector argument which takes "sync" vector
//by reference
manipulator.flip(bitsetIndex);
Since, I am passing my vector by reference, I wanted to make changes to it. i.e. whatever changes I have made to my bitset, I wanted to commit it to the vector too. However, I am not sure how to convert a bitset to an unsigned char and how to assign it to my vector, in order to update my vector sync.