You can operate directly on the std::bitset
as if it were an array, because the []
operator is conveniently overloaded for you, e.g.
std::bitset a, b, c;
for (i = 0; i < a.size(); ++i)
c[i] = a[i] ^ b[i]; // c = a XOR b
(Note: this assumes that a
, b
and c
all have the same size.)