[std-interval] Interval comparison operators

Fernando Cacciola fernando_cacciola at datafull.com
Wed Apr 26 17:42:16 PDT 2006


Guillaume Melquiond wrote:
> Le mercredi 26 avril 2006 à 18:17 +0000, first.i.last at comcast.net a
> écrit :
>
>>>         if (certainly(X < Y)) ...
>>
>> Does this mean
>>
>>     if ( certainly_lt(X,Y) )
>>
>> Or does operator<(interval,interval) return a specialized object that
>> certainly(/*special object*/) reduces to a boolean or an exception?
>
> 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.

The proposal itself could be more abstract, like:

Interval comparison operators return an object of an unspecified type 
representing a tristate boolean with valid states True, False and neither 
True nor False.
These states are accessible via:

bool certainly    (value) -> true if the state is True, false otherwise
bool certainly_not(value) -> true if the state is False, false otherwise
bool possibly     (value) -> true if the state is NOT False, false otherwise
bool possibly_not (value) -> true if the state is NOT True, false otherwise

and can be logically combined via:

valueR = valueL | valueR (OR)
valueR = valueL & valueR (AND)

In a boolean context, such object shows undefined behaviour if the state is 
not True or False.


That is, the specification of the comparison operator's result can be 
spelled as a Concept rather than a concrete type.
This leaves the details of the actual representation of the operator result 
to the implementator. The proposal itself would only list the "states" 
required for each result.

Fernando Cacciola
SciSoft
http://fcacciola.50webs.com/




More information about the Std-interval mailing list