Ordering of boolean values

后端 未结 7 1756
醉酒成梦
醉酒成梦 2021-02-18 17:02

Under C++ or from C99, how is the less-than operator < defined for boolean values?

Alternatively, explain the behaviour of

7条回答
  •  滥情空心
    2021-02-18 17:56

    operator > and < base on this:

    true == (1)
    false == (0)
    

    this false: (bool)-1 < true (bool)-1 < false because of rolling arithmetic in bool b = -1;

提交回复
热议问题