[std-interval] Interval comparison operators

Guillaume Melquiond guillaume.melquiond at ens-lyon.fr
Wed Apr 26 22:52:54 PDT 2006


Le mercredi 26 avril 2006 à 16:42 -0300, Fernando Cacciola a écrit :

> > I really meant "certainly(X < Y)". And yes, this presumably requires
> > the use of some kind of an expression template as the return type of
> > operator<. So "certainly" will do the actual comparison and return a
> > boolean (and it will _never_ throw an exception).
> >
> FWIW the operator doesn't "have to" return an expression template letting 
> "certainly" do the actual comparison.
> It could also be that the operator returns a tribool, or a discrete interval 
> over 'bool', so that "certainly" just turns that into a true/false.

Right. And a discrete interval over bool is actually used in the
original draft and in our toy implementation :-). I just missed a part
of my sentence: I wanted to say that, _for performance reasons_, the
return type will presumably be an expression template. A discrete
interval works well, but since the comparison is not delayed, it
requires some more tests (usually three instead of one floating-point
comparison) and a compiler cannot optimize them away without some
interval arithmetic related knowledge. We also intended for the
comparison operators to produce such a discrete interval (originally
called interval<bool>, but there was a lot of complains about the name)
when needed.

Best regards,

Guillaume



More information about the Std-interval mailing list