
17 Nov
2009
17 Nov
'09
3:18 p.m.
On Mon, Nov 16, 2009 at 4:08 PM, Patrick Horgan <phorgan1@gmail.com> wrote:
C4800 Might suggest that they use a bool valued expression in the first place, i.e. instead of foo, foo!=0, or do a static cast to bool. This is at times indicative of real bugs, when people turn out to not be doing what they thought they were doing. Apparently this is one of my favorite bugs (by favorite I don't mean that I like it either!)
C4800: int' : forcing value to bool 'true' or 'false' I'm a big fan of using !! to convert to bool: bool has_item() { Foo * foo = find_item(); return !!foo; // convert ptr to bool } Is that too subtle for others? It wouldn't be too subtle if it became a common idiom. :-) Tony