In message < >, Old Wolf
<> writes
>Richard Herring <junk@[127.0.0.1]> wrote:
>> Old Wolf writes:
>> >"Siemel Naran" <> wrote:
>> >>
>> >> Question: what is the type of !(d_flags & flag ).
>> >
>> >The results of && || ! are all int.
>>
>> Not according to ISO14882 sections 5.3.1, 5.14 and 5.15:
>> "The result is a bool".
>
>How right you are
>
>> >> This would mean converting an int to bool, which I imagine is internally
>> >> something like
>> >>
>> >> if (value != 0) result = 1;
>> >> else result = 0;
>> >>
>> >> Thus !(d_flags & flag) is
>> >>
>> >> if (d_flags & flag == 0) result = 1;
>> >> else result = 0;
>> >
>> >I don't know why so many people have misgivings about "int to bool
>> >conversions".
>>
>> I don't know why so many people have misgivings about the argument and
>> result types of !, && and ||.
>
>It's different in C.
It would have to be. C had no bool type.
>But this is a different issue to int-to-bool
>conversions, which the OP was asking about.
>
>> >false is zero and true is non-zero. This was the case
>> >even before computers were invented. No assembly instructions are
>> >required.
>>
>> There's at least one architecture where even=>false and odd=>true.
>
>Irrelevant to C++ (as was the original point, too)
You're the one who raised assembly instructions.
--
Richard Herring
|