Files
2025-10-25 03:02:53 +03:00

42 lines
1.6 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[class.eq]
# 11 Classes [[class]](./#class)
## 11.10 Comparisons [[class.compare]](class.compare#class.eq)
### 11.10.2 Equality operator [class.eq]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/classes.tex#L6693)
A defaulted equality operator function ([[over.binary]](over.binary "12.4.3Binary operators"))
shall have a declared return type bool[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/classes.tex#L6697)
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]](class.compare.default "11.10.1Defaulted comparison operator functions"))[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/classes.tex#L6705)
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[.](#3.sentence-1)
The return value is false if such an index exists
and true otherwise[.](#3.sentence-2)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/classes.tex#L6717)
[*Example [1](#example-1)*: struct D {int i; friend bool operator==(const D& x, const D& y) = default; // OK, returns x.i == y.i}; — *end example*]