I want to have a decrement operator for a bitstring. I currently have an incremement operator defined as follows:
void increment(boost::dynamic_bitset<> &bitset)
{
for (int loop = 0; loop < bitset.size(); ++loop)
{
if ((bitset[loop] ^= 0x1) == 0x1)
{
break;
}
}
}
How would I decrement in a bitstring?
It seems like this would work.
void decrement(boost::dynamic_bitset<> &bitset)
{
for (int loop = 0; loop < bitset.size(); ++loop)
{
if ((bitset[loop] ^= 0x1) == 0x0)
{
break;
}
}
}