Boost logo

Boost :

From: Powell, Gary (powellg_at_[hidden])
Date: 2004-05-25 17:06:27

I have read the docs and the code and I vote for acceptance. Implementation details aside as to whether the results of logic operators should be table lookups or not.

I have not compiled the code but I will.

>> 9. Silly question: is there way to use ternary operator
>> somehow to initialize tribool conditionally:
>> tribool t(x ? true : indeterminate); // something like that

>Unfortunately, I don't know of a way to get the conversions to work out
>right for that. If only we could overload the ternary operator :(

Don't you want a quaternary operator?

tribool t( x ? true_fn() : maybe_fn() : false_fn() );

(And yes I'd like to overload the ternary operator! But for other reasons...lambda one of them.)

As a total aside, the only time I've needed anything like this I used a fuzzy_bool which had values from zero to one representated by a float. Then "indeterminate" fluxuates closer or farther from "true" and "false". With an optional latch function that prevents the shift in states from true to false until some threshold has been exceeded. I suspect that many users of tribool would be better off with such a beast. But that doesn't change my vote for this one.


Boost list run by bdawes at, gregod at, cpdaniel at, john at