On Sat, 22 Mar 2003 20:11:23 +0000, Kevlin Henney
<[EMAIL PROTECTED]> wrote:

>In article <[EMAIL PROTECTED]>, Terje Slettebų
><[EMAIL PROTECTED]> writes
>>
>>Regarding the other MSVC 6 warning given in the original report, Gennaro
>>Prota has suggested using an explicit "!=", rather than relying on the
>>implicit conversion from pointer to bool. This also avoids using a cast,
>>instead.
>
>Or one could use "stream << input && true" ;-) However, I think if one
>is going to twist the expression of the code to satisfy the misplaced
>oversensitivity of VC, it may be better to be more explicit than subtle,
>ie "!(stream << input).fail()".

That's fine too. Of course these are style/personal-taste issues. I'm
sure there's someone claiming that !! is clearer :-) More to the
point, I just suggested the way I *generally* use to shut up VC in
such cases; it' obvious that !(expr).fail() is something rather
stream-specific, whereas an explicit compare with != works any time
you have a boolean conversion.

The typical case where that warning appears with VC++ is when you
attempt to return directly the result of an API call that returns a
BOOL from a function that returns bool; e.g.:

bool IsThereAMouseHere() {
    return ::GetSystemMetrics(SM_MOUSEPRESENT);
}

In that case an explicit compare with FALSE seems reasonable.


Genny.

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Reply via email to