Boost logo

Boost Users :

Subject: Re: [Boost-users] Small logic::tribool riddle
From: Krzysztof Czainski (1czajnik_at_[hidden])
Date: 2011-03-11 07:12:58


2011/3/11 Thomas Jarosch <thomas.jarosch_at_[hidden]>

> 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?
>
> A coworker just shot himself in the foot...
>
> Best regards,
> Thomas Jarosch
>

Without looking in the docs; I havent used tribool in my life ;-)

My guess is:
1) foo is intermediate => prints reached2 (cause I expect foo != true to
return intermediate)
2) foo is true => prints nothing
3) foo is false => prints reached1

Now I'll check the docs...

Regards,
Kris



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net