Boost logo

Boost Users :

Subject: Re: [Boost-users] boost::tribool "if ( someTriboolVar == indeterminate )" semantics is confusing
From: Gavin Lambert (gavinl_at_[hidden])
Date: 2014-03-06 17:16:49

On 6/03/2014 17:06, Quoth Peter Hackett:
> I had code that did something like:
> tribool triboolVar1 = indeterminate;
> if ( triboolVar1 == indeterminate ) {
> cout << "triboolVar1 is indeterminate" << endl;
> } else {
> cout << "triboolVar1 is NOT indeterminate" << endl;
> }
> I was expecting this to print "triboolVar1 is indeterminate".
> However it prints "triboolVar1 is NOT indeterminate".

Shows the correct way to test for an indeterminate value.

I thought there was a truth-table for operator== on that page too, but
apparently not. Maybe I'm thinking of a different library that had a
similar class.

> Shouldn't an "indeterminate" value equal another "indeterminate" value?

No, they're like database NULLs. They're never equal to anything, not
even themselves. (Since, after all, two things that are unknown by
definition cannot be known to equal each other.)

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at