Extends.
I thought I was being cool when I did something like:
bool hasParent()
{
return this->parentNode ;
}
Even with a (bool) cast, the warning still doesn't go away.
Where this->parentNode is NULL when there is no parent node.
But I'm getting:
warning C4800: 'Node *' : forcing value to bool 'true' or 'false' (performance warning)
What's the deal, yo? Why is that a performance warning? I thought it'd be more efficient to not write something like:
bool hasParent()
{
if( this->parentNode )
return true ;
else
return false ;
}
But the second version generates no warnings and the compiler seems a lot happier. Which is faster though?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…