|
Boost : |
From: Corrado Zoccolo (czoccolo_at_[hidden])
Date: 2008-05-22 06:58:48
On Wed, May 21, 2008 at 6:28 PM, Simonson, Lucanus J <
lucanus.j.simonson_at_[hidden]> wrote:
> I'm going to agree with Jim here. The bitwise operators are a better
> choice for overloading than the logical, which imply flow control.
There is still a problem with this approach. The non overloaded operators ||
and && will usually do the wrong thing, causing the tribool to be first
converted to bool, and then to go through the short-circuited evaluation.
This means relations like: !a && !b == !(a || b) will not hold any more
(just take a and b to be indeterminate).
This will be much more surprising, IMO.
You should disable operators || and && completely using private overloads.
I also agree with him that short-circuiting can't be implemented. If you
> have expression templates as someone else suggested you could short
> circuit evaluating your own expressions, but not short circuit
> evaluating other code, only the compiler can do that:
>
> A || B || foo(C);
>
In my post, I said that the final user still has to delay the calls to his
code to make the ET approach work, so it is not transparent. This is usual
for expression templates that represent code to be evaluated, look for
example at boost::lambda.
Corrado
Luke
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>
-- __________________________________________________________________________ dott. Corrado Zoccolo mailto:czoccolo_at_[hidden] PhD - Department of Computer Science - University of Pisa, Italy -------------------------------------------------------------------------- The self-confidence of a warrior is not the self-confidence of the average man. The average man seeks certainty in the eyes of the onlooker and calls that self-confidence. The warrior seeks impeccability in his own eyes and calls that humbleness. Tales of Power - C. Castaneda
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk