gpt4 book ai didi

c++ - 警告 C4800 : 'int' : forcing value to bool 'true' or 'false' (performance warning)

转载 作者:IT老高 更新时间:2023-10-28 12:42:52 24 4
gpt4 key购买 nike

我的代码中有这个问题:

bool CBase::isNumber()
{
return (id & MID_NUMBER);
}

bool CBase::isVar()
{
return (id & MID_VARIABLE);
}

bool CBase::isSymbol()
{
return (id & MID_SYMBOL);
}

最佳答案

仅供引用:强制转换不会隐藏警告 by design .

类似

return (id & MID_NUMBER) != 0;

应该明确说明“我要检查这个值是否为零”并让编译器高兴

关于c++ - 警告 C4800 : 'int' : forcing value to bool 'true' or 'false' (performance warning),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20919650/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com