Boost logo

Boost :

From: Jeremy Siek (jsiek_at_[hidden])
Date: 2001-09-27 00:20:06


On Thu, 27 Sep 2001, Daryle Walker wrote:
daryle> You guys are seeing total v. partial ordering as a local
daryle> thing, I see it as a global thing. Think about the IEEE
daryle> floating point numbers; usually any pair of numbers you
daryle> compare are going to be ordered, so a total ordering
daryle> evaluation will work. However there is one valid value
daryle> that is not ordered, NaN, so the IEEE numbers are globally
daryle> only partially ordered.

I understand what you are saying, but I still think it is wrong.

daryle> In most circumstances, the iterators you compare will be
daryle> from the same container, so a total ordering seems to
daryle> work. But if you get two arbitrary, yet valid, iterators,
daryle> their comparisons (besides not-equal) should be FALSE
daryle> because you don't know if the iterators use the same
daryle> container. So iterators are globally partially ordered.
daryle> An alternative would be to declare potential
daryle> cross-container comparisons as undefined. Shouldn't we
daryle> give the user a nicer response?

We don't need say anything about ordering for two itereators from
different containers (your global ordering)... any operation between two
such iterators is undefined (and should result in an exception for the
debug version of the library). The two iterators are in separate domains.
Note that being of the same "type" in C++ does not mean we have to say
that two things are in the same domain. Take for example matrix addition.
Addition is only defined when the dimensions of the matrix match up...
even though they have the same type. And again, in this case an exception
would be thrown.

We only need to define ordering for iterators in the same container, and a
total ordering is the right choice there.

Cheers,
Jeremy

----------------------------------------------------------------------
 Jeremy Siek http://php.indiana.edu/~jsiek/
 Ph.D. Student, Indiana Univ. B'ton email: jsiek_at_[hidden]
 C++ Booster (http://www.boost.org) office phone: (812) 855-9761
----------------------------------------------------------------------


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