|
Boost : |
From: Herve Bronnimann (hbr_at_[hidden])
Date: 2002-09-03 16:11:07
On Tue, Sep 03, 2002 at 04:36:10PM -0400, David Bergman wrote:
> The C++ Standard gives us a default implementation of "<=" in terms of
> "! >". That default behavior should be overridden when that is no longer
> true w.r.t. logic. That is why I used the hard word "wrong", cause it is
> "wrong" as in illogical to have (in a domain with proper equivalence)
>
> a <= b != a < b || a == b
On the other hand, out of sheer honesty, and because someone else might
notice and hold it against me not to say it loud, I have to agree with
you on one point. Even though on all the examples you supplied, !(a<b) &
(!(b<a) means overlap, there is a snag: this is not an equivalence
relation. Indeed, [0,2] overlaps with [1,4], which overlaps with [3,5],
but [0,2] does not overlap with [3,5].
What this means is that there is no hope of defining operator< in a way
that is compatible with the operator< for the base type, idem for
operator>, <=, and >=, and still hope to have nice mathematical
properties. But I take this as one more reason to proceed as we did,
i.e. carefully and documentedly, providing extra functions cerlt, etc.
Those should be useful in whatever you are doing since they essentially
reduce to bounds comparison.
The other option is, like Profil/BIAS, to define operator< in terms of
subset, superset, etc. That has the mathematical consistency.
By the way, I appreciate the discussion and the arguments provided so
far have been fair. I was not expecting less from the gentle boosters.
Regards,
-- Hervé
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk