在算数运算中,能否将 bool 值 true 视作 1?
true == 1;
true + 1;
If the destination type is bool, see 4.12. If the source type is bool, the value false is converted to zero and the value true is converted to one.
在算数运算中 bool 类型会被提升成整型,true 会被转换成 1,false 会被转换成 0。
参考资料

浙公网安备 33010602011771号