|
Boost : |
From: Douglas Gregor (gregod_at_[hidden])
Date: 2002-09-02 21:43:05
On Monday 02 September 2002 02:02 am, Guillaume Melquiond wrote:
> > It's semantics correspond to the default Comparison policy
> > (compare_certainly).
>
> If I clearly understand what you mean, I need to disagree. The
> compare_certainly policy has been conceived to return a boolean value (the
> comparisons only answer "true" when the result is precisely "true").
I mispoke. If the return value were tribool then comparisons would act
similarly to those with bool return values and the compare_certainly policy
in boolean contexts, because with something like:
interval<int> i,j; // init i, j
if (i < j) {
// ...
}
would act the same. tribool returns true in a boolean context when the value
is definitely/certainly true. Unfortunately, this would act differently:
interval<int> i,j; // init i, j
if (!(i < j)) {
// ...
}
compare_certainly would enter the if when it is not certain that i < j,
whereas tribool would enter the if when it is certain that !(i < j).
Essentially, the effect of the policy disappears once the result is converted
to a bool. So compare_certainly can't state that 'the result of a boolean
expression involving a comparison is true if the expression is certainly
true', but is required to state the weaker 'the result of a comparison is
true if the comparison is certainly true'.
Doug
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk