[expr.eq] (original) (raw)

7 Expressions [expr]

7.6 Compound expressions [expr.compound]

7.6.10 Equality operators [expr.eq]

The == (equal to) and the != (not equal to) operators group left-to-right.

The lvalue-to-rvalue ([conv.lval]) and function-to-pointer ([conv.func]) standard conversions are performed on the operands.

If one of the operands is a pointer or a null pointer constant ([conv.ptr]), the array-to-pointer conversion ([conv.array]) is performed on the other operand.

The converted operands shall have scalar type.

The operators== and != both yield true or false, i.e., a result of type bool.

In each case below, the operands shall have the same type after the specified conversions have been applied.

Comparing pointers is defined as follows:

If at least one of the operands is a pointer to member, pointer-to-member conversions ([conv.mem]), function pointer conversions ([conv.fctptr]), and qualification conversions ([conv.qual]) are performed on both operands to bring them to their composite pointer type ([expr.type]).

Comparing pointers to members is defined as follows:

Two operands of type std​::​nullptr_t or one operand of typestd​::​nullptr_t and the other a null pointer constant compare equal.

If two operands compare equal, the result is true for the == operator and false for the != operator.

If two operands compare unequal, the result is false for the == operator andtrue for the != operator.

Otherwise, the result of each of the operators is unspecified.

If both operands are of arithmetic or enumeration type, the usual arithmetic conversions ([expr.arith.conv]) are performed on both operands; each of the operators shall yieldtrue if the specified relationship is true and false if it is false.