Boost logo

Boost :

Subject: Re: [boost] [dynamic_bitset] Comparison operators without assertions
From: Peter Bartlett (pete_at_[hidden])
Date: 2017-05-11 00:28:36

Edward wrote:

>Given that there is an ordering I agree with the OP that an assertion, when
bitsets are a different size and an ordering operator is used, is not the
right way that >dynamic_bitset should have been designed. But what should be
done I do not know and am perfectly willing to defer to others on this, as I
am just a maintainer >and not the original developer.

I don't think there is an truly natural ordering because you'd want, say,
'00' not to be equal to be '0' but under any natural ordering they'd map to
the same integer, 0.

So you have two options:
        - consider length first and if they are equal consider the bit
pattern using the ordering you have now.
        - consider common bits first (i.e. given lengths M,N consider
the last min(N,M) bits of each). If they are equal consider the length
(longer is greater).

Either of these would be compatible with the equal-size ordering that is
currently present.
I would imagine the latter is better because it implies '00' < '1' which is
less surprising than the former ('00' > '1')


Boost list run by bdawes at, gregod at, cpdaniel at, john at