Boost logo

Boost :

From: John Maddock (John_Maddock_at_[hidden])
Date: 2000-11-25 07:27:28


>Ok, what we probably need is a several variants of LessThanComparable.
>Here's the first two:
>
>LessThanComparable<T> (matches the standard)
> T a, b;
> a < b
>
>Comparable<T> (matches SGI STL definition)
> T a, b;
> a < b
> a <= b
> a > b
> a >= b

Yes.

>lower_bound(ForIter first, ForIter last, T value)
>
>The standard says T must be LessThanComparable. As I mentioned
>before, this is somewhat irrelevant unless we also add the
>requirement that iterator_traits<ForIter>::value_type is
>the same type as T... but I don't think we want to add that.

That isn't required: we only require that T be convertible to
iterator_traits<ForIter>::value_type, if someone wants to add extra
signatures to the comparison operator to avoid unnecessary coversions then
that's OK, but I don't see LessThanComparable2<A,B> as being required here
(although it can't do any harm).

>I'm in favor of the above, though I could also see people arguing that if
>"a < b" is a valid expression for the concept, then so should "b > a",
>which would add the greater-than operator.

No there is no requirement for >, if the ordering is weak then it can be
very dangerous indeed to assume that there is any mathematical relationship
between the various operators, the only thing you can rely on is that there
is one operator (possibly operator<) that produces a strict ordering.

- John.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk