I like (bool) way more, but it generates warnings. How do i get rid off the warnings?
I have code like:
bool something_else = 0;
void switcher(int val = -1){
if(val != -1){
something_else = (bool)val;
}else{
something_else ^= 1;
}
}
Should i just do it like everyone else and use '!!' or make it somehow hide the warning messages when using (bool) ? Or is '!!' actually faster than (bool) ?
I would like to use (bool) and so i have to hide the warning, but how?
Edit: Visual Studio 2008 i am using, sorry i forgot to tell.
Edit 2: The warning message is warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
And it comes on the line something_else = (bool)val;
And on the line something_else = val;
But not on the line something_else = !!val;
The problem is, i want it to respect that i want to convert it to boolean. I dont want to hide all boolean warnings, because sometimes they saved my ass.