Boost logo

Boost :

From: Sylvain Pion (pion_at_[hidden])
Date: 2002-09-01 21:11:43


On Sun, Sep 01, 2002 at 06:05:05PM -0700, Carl Daniel wrote:
> If one orders the internal comparision results as
> {false,indeterminate,true}, then there is a sensible definition for all of
> the common logic operations (assume false -> true correspond to values 0, 1,
> 2):
>
> a AND B = min(a,b)
> a OR b = max(a,b)
> NOT a = 2-a
>
> XOR can be implemented via table, or by it's basic definition:
>
> a XOR b = (a AND NOT b) OR (b AND NOT a)
>
> Would that be a useful addition to the library? I suppose it would require
> that the relational operators return a UDT to allow overloading (perhaps
> they do already? I haven't even looked yet).

Actually, we raised this precise question internally already, because it's true
that the comparisons have logically 3 states.
We did not implement it, because the question of usefulness is still
undecided, and there is a need to define a clean logic over this type.

Having the comparison operators return something else than bool can probably be
somewhat confusing and risky. It all depends if there is a clearly defined
logic over these tri-state types. I have not followed the boost::tribool
discussions in detail, but this might be a possible connection.

As to a possible implementation, I guess that the Comparison policy could
easily provide the return type of the comparison operators over intervals
(currently hard wired to bool).
And then it just becomes a matter of writing a particular comparison policy
class.

-- 
Sylvain

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