|
Boost : |
From: Daryle Walker (darylew_at_[hidden])
Date: 2000-10-25 14:00:41
The relation operator classes (like less_than_comparable) in
"operators.hpp," and the standard assume that:
x != y maps to !(x == y)
x > y maps to (y < x)
x <= y maps to !(y < x)
x >= y maps to !(x < y)
But doesn't this assume that every object of a type can be put into an
order, so it can be related with every other object? What about types that
have object(s) that incomparable with (a subset of) other objects of that
type? (Example: IEEE 754 floating point NaN values don't compare with
anything.) The assumed relations won't hold; since all the relations,
except for inequality, should give false.
Should we have another operator class, similar to the less_than_comparable
family, that builds the comparisons such that they are safe for this
problem:
x != y maps to !(x == y)
x > y maps to (y < x)
x <= y maps to (x < y) || (x == y)
x >= y maps to (x > y) || (x == y)
The first two are the same because only the last two have the problem.
-- Daryle Walker Mac, Internet, and Video Game Junkie darylew AT mac DOT com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk