In VS 10 I get a warning:
warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
trying to compile
int x ;
static_cast<bool>(x);
How is it possible to write a code which doesn`t cause this warning?
In VS 10 I get a warning:
warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
trying to compile
int x ;
static_cast<bool>(x);
How is it possible to write a code which doesn`t cause this warning?
int x ;
bool b1 = !!x; // common idiom; get used to it. "Newcomers" just need to learn the idiom.
bool b2 = x!=0; // another way, less idiomatic
It is a stupid warning and can be ignored/disabled. There is no performance issue as far as I know.