Is there a way of performing bitwise operations on two std::bitsets of different sizes?
Something similar to this:
std::bitset<8> payload { 0b1010'0010 };
std::bitset<10> segment { 0b00'0000'0000 };
segment |= payload;
For the above example, I basically want to transfer all the 8 bits of payload to the lower bits of segment. What other options do I have if this cannot be done? Should I write a for loop that uses the subscript operator[] to transfer the bits one by one?
Convert the narrower to the wider one then you can use
|=:For wider ones you can use
to_stringand the constructor creating the bitset from a string.