On Friday, 11. March 2011 13:14:13 Sebastian Redl wrote:

> > if (foo == boost::logic::indeterminate)

> > {

> >

> > std::cout<< "reached2\n";

>

> ...

>

> If you see tribool as a type that can have the three distinct values

> "true", "false", and "indeterminate", then no, it's not intuitive.

> If you instead see tribool as having the two values "true" and "false"

> and in addition the state "indeterminate", which means "could be true or

> false, not sure", then the result of the comparison operators is

> intuitive, but the way they behave in conditions still isn't.

Thanks everyone who replied to the riddle.

I see this in a way of "three-valued logic" as tribool is homed at

boost/logic/tribool.hpp. Boolean logic operations are AND, OR and NOT.

Element comparison of a defined set is not a Boolean logic operation.

Therefore overriding the comparison operator complicated

the use of this library a lot. I showed the example to six

programmers and they all got it wrong.

Or just have a look at this one:

http://stackoverflow.com/questions/3495428/boosttribool-odd-behaviour-or-bug

Certainly the original intention was to make life easier for everyone

by overriding the operator==(). Unfortunately this doesn't seem to be the case, sophisticated professionals or people unfamiliar with the exact details of the boost::tribool operator==() fail at it.

I'm also aware that this interface is in public use

and can't be changed easily to avoid usage errors.

Or can it?

Best regards,

Thomas