It comes out like this on my computer (Centos 7, gcc 4.8.2), but I wonder if other computers get the same results unconditionally.
c++ boolean language-lawyer comparison-operators
The operations for true
and false
are set in the C++ standard.
More specifically, in C++ standard
Section 5.9 Relational Operators are
For operands arithmetic, enumeration, or pointer type, type std::nullptr_t
The results of the operators <, >, <=, >= are said to result in true
/false
of the boolean type.
In the Fundamental types in Section 3.9.1,
Bool, char, char16_t, char32_t, wchar_t, signed/unsigned integrer types are called integrals Integral type and floating type are called arithmetical types.
Section 4.5 is
The prvalue of the bowl type can be converted to the prvalue of the int type. In this case, false is 0, and true is 1.
Put it all together.
This is.
© 2024 OneMinuteCode. All rights reserved.