문제

I'm exploring boost::tribool and was surprised by the following behaviour.

{
using namespace boost;

boost::tribool t(indeterminate);

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

However, if I do this, the assert passes.

assert(indeterminate(t));

No compiler warnings or errors in either case. Anyone have a good explanation of why this should be??

도움이 되었습니까?

해결책

I think the answer is in the documentation:

the result of comparing two indeterminate values is indeterminate (not true) - we don't know what the values are, so we can't tell that they are equal;

the indeterminate function can be used to test if a tribool is in an indeterminate state.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top