Boost logo

Boost :

From: Kevlin Henney (kevlin_at_[hidden])
Date: 2000-09-07 07:25:52

In message <004501c018bc$c760c4e0$520a24d4_at_pdimov>, Peter Dimov
<pdimov_at_[hidden]> writes
>The standard does not assume that !(a < b) && !(b < a) implies a == b.

True, but it's the closest to hand for an equivalence relationship.

I think it is strange (nonintuitive, indeed) to define relational
operators such that

        !(a < b) && !(b < a) does not imply a == b

Don't you think? Subset and subtyping relationships often use the
notation like this, but I think that is a questionable route and
fortunately one that the STL chose not to follow, preferring
lexicographical_compare instead. That said, I would prefer any of those
interpretations above unspecified (and that preference is ordered ;->).

>> Therefore a precondition to operator< working is that the contents have
>> a valid operator<?
>No. ref::operator<, when invoked on refs holding objects of the same type T,
>produces the same ordering as the statically-typed version.

Except when they don't have an operator<: How can you produce the same
ordering as the statically-typed version when the statically-typed
version does not compile? Mu!

So the precondition I stated still holds, although I should have been
more careful in expressing it: "Therefore a precondition to operator<
working is that the contents (1) have an operator<, and (2) it imposes a
strict weak ordering".

>> >ref(T t) < ref(U u) iff T < U || (T == U && t < u).
>> That's not the same as what the current ref<> does.
>The current ref::op< does
>ref(T t) < ref(U u) iff T == U? t < u: T < U
>which is equivalent to the above.

Which is still not the same! If T == U, and t < u is not a legal
expression, it still introduces an ordering, therefore it is not "iff".

This also brings us back again to T < U being intuitive: Until you
started outlining ref<>'s semantics, the only common definition of which
I was aware for interpreting this notation was "T is a subtype of U"
(which is not in fact a strict weak ordering). Hmm, even since, I still
reckon that's the only common definition ;-)

No, in fact, I'm even more convinced: How can "unspecified" be a more
intuitive definition than "is a subtype of", or "is included within", or
"is less than", or "is lexicographically less than"? Just because it has
wings doesn't mean it can fly.


  Kevlin Henney phone: +44 117 942 2990
  Curbralan Limited mobile: +44 7801 073 508
  mailto:kevlin_at_[hidden] fax: +44 870 052 2289

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