Boost :: tribool: weird behavior or bug?

I am learning boost :: tribool and was surprised by the following behavior.

{
using namespace boost;

boost::tribool t(indeterminate);

assert(t==indeterminate);  // This assertion fails!
} 

However, if I do, approval will pass.

assert(indeterminate(t));

There are no warnings or compiler errors in any way. Does anyone have a good explanation why this should be?

+5
source share
1 answer

I think the answer is in the documentation :

the result of comparing two undefined values ​​is undefined (not true) - we do not know what the values ​​are, therefore we cannot say that they are equal;

indeterminate , .

+11

All Articles