Boost logo

Boost :

Subject: Re: [boost] [dynamic_bitset] Comparison operators without assertions
From: Edward Diener (eldiener_at_[hidden])
Date: 2017-05-11 01:15:06


On 5/10/2017 8:28 PM, Peter Bartlett via Boost wrote:
> 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).

I do not understand the difference above. Currently when the sizes are
equal the algorithm compares the bits from right to left, else asserts.
Your second choice above would do the same when the sizes are equal, but
always specify the longer length as greater rather than assert if the
same length bits are equal. I agree with how you suggest to change it,
but between the first and second above, when the sizes are equal I see
no difference. Or do you mean to suggest that your second choice would
compare the last min(N,M) bits from left to right to determine ordering
rather than the current right to left ?

>
> 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 acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk