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

61 lines
2.1 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.compare.secondary]
# 11 Classes [[class]](./#class)
## 11.10 Comparisons [[class.compare]](class.compare#secondary)
### 11.10.4 Secondary comparison operators [class.compare.secondary]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/classes.tex#L6855)
A [*secondary comparison operator*](#def:secondary_comparison_operator "11.10.4Secondary comparison operators[class.compare.secondary]") is
a relational operator ([[expr.rel]](expr.rel "7.6.9Relational operators")) or the != operator[.](#1.sentence-1)
A defaulted operator function ([[over.binary]](over.binary "12.4.3Binary operators"))
for a secondary comparison operator @ shall have a declared return type bool[.](#1.sentence-2)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/classes.tex#L6863)
The operator function with parameters x and y is defined as deleted if
- [(2.1)](#2.1)
a first overload resolution ([[over.match]](over.match "12.2Overload resolution")),
as applied to x @ y,
* [(2.1.1)](#2.1.1)
does not result in a usable candidate, or
* [(2.1.2)](#2.1.2)
the selected candidate is not a rewritten candidate, or
- [(2.2)](#2.2)
a second overload resolution for
the expression resulting from the interpretation of x @ y using the selected rewritten candidate ([[over.match.oper]](over.match.oper "12.2.2.3Operators in expressions"))
does not result in a usable candidate
(for example, that expression might be (x <=> y) @ 0), or
- [(2.3)](#2.3)
x @ y cannot be implicitly converted to bool[.](#2.sentence-1)
In any of the two overload resolutions above,
the defaulted operator function is not considered as
a candidate for the @ operator[.](#2.sentence-2)
Otherwise, the operator function yields x @ y[.](#2.sentence-3)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/classes.tex#L6892)
[*Example [1](#example-1)*: struct HasNoLessThan { };
struct C {friend HasNoLessThan operator<=>(const C&, const C&); bool operator<(const C&) const = default; // OK, function is deleted}; — *end example*]