Files
cppdraft_translate/cppdraft/class/eq.md
2025-10-25 03:02:53 +03:00

1.6 KiB

[class.eq]

11 Classes [class]

11.10 Comparisons [class.compare]

11.10.2 Equality operator [class.eq]

1

#

A defaulted equality operator function ([over.binary]) shall have a declared return type bool.

2

#

A defaulted == operator function for a class C is defined as deleted unless, for each xi in the expanded list of subobjects for an object x of type C,xi == xi is usable ([class.compare.default]).

3

#

The return value of a defaulted == operator function with parameters x and y is determined by comparing corresponding elements xi and yi in the expanded lists of subobjects for x and y (in increasing index order) until the first index i where xi == yi yields a result value which, when contextually converted to bool, yields false.

The return value is false if such an index exists and true otherwise.

4

#

[Example 1: struct D {int i; friend bool operator==(const D& x, const D& y) = default; // OK, returns x.i == y.i}; — end example]