|
Boost : |
From: Corrado Zoccolo (czoccolo_at_[hidden])
Date: 2008-05-21 02:57:56
On Tue, May 20, 2008 at 4:13 PM, klaus triendl <klaus_at_triendl.eu> wrote:
>
>
> Hmm, I didn't look thoroughly at it but wouldn't it be possible to
> remove these overloads?
> I've seen a proposal for bool_set that doesn't overload (anymore) the
> two logical operators.
>
I don't think you can get rid of the overloads.
The overloads are needed to implement the truth tables (see
http://www.boost.org/doc/libs/1_35_0/doc/html/boost/logic/operator_id257657.htmland
http://www.boost.org/doc/libs/1_35_0/doc/html/boost/logic/operator!_id340819.html
).
In order to remove them, you need a conversion C: tribool-> bool that
preserves all the truth tables, and is an homomorphism, i.e.
C( op(X) ) == op( C(X) ) and C( X op Y ) == C(X) op C(Y)
Unfortunately, if such conversion existed, then :
C(indeterminate) = C(!indeterminate) = !C(indeterminate)
that is impossible for a bool.
Do you really need tribool semantics, or you just needed something like
optional<bool>?
One thing that can be done is to use expression templates to build the
operator expressions, and implement short circuit evaluation on top of them,
but then you have to pay attention to how you build your expression, because
you have to explicitly delay expressions like *a_bool_pointer.
Corrado
-- > Klaus > > _______________________________________________ > 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