
On Fri, Mar 11, 2011 at 11:53 AM, Thomas Jarosch < thomas.jarosch@intra2net.com> wrote:
Hello,
here's a small boost::logic::tribool riddle:
-<snip>-------------------------------------
#include <iostream> #include <boost/logic/tribool.hpp>
int main(void) { boost::logic::tribool foo(boost::logic::indeterminate); if (foo != true) { std::cout << "reached1\n"; }
if (foo == boost::logic::indeterminate) { std::cout << "reached2\n"; }
return 0; }
-<snap>-------------------------------------
Try to determine the printed result without looking at the boost::logic::tribool implementation / documentation.
Intuitive?
Ok, I guessed, got it wrong, read the docs, and still don't get it! Modifying your example to... #include <iostream> #include <boost/logic/tribool.hpp> int main(void) { boost::logic::tribool foo(boost::logic::indeterminate); if (foo != true) { std::cout << "reached1\n"; } if (foo == boost::logic::indeterminate) { std::cout << "reached2\n"; } if (boost::logic::indeterminate == boost::logic::indeterminate) { std::cout << "reached3\n"; } return 0; } only prints "reached3", so I can see the logic of second test being indeterminate rather than true, but then surely the comparing indeterminate with indeterminate should also be true? Weird! - Rob.