Boost::tribool: odd behaviour, or bug?
Question
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??
Solution
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.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow