11 Classes [class]

11.11 Comparisons [class.compare]

11.11.3 Three-way comparison [class.spaceship]

The synthesized three-way comparison of type R ([cmp.categories]) of glvalues a and b of the same type is defined as follows:
Note
:
A synthesized three-way comparison may be ill-formed if overload resolution finds usable functions that do not otherwise meet the requirements implied by the defined expression.
— end note
 ]
Let R be the declared return type of a defaulted three-way comparison operator function.
Given an expanded list of subobjects for an object x of type C, let be the type of the expression <=> , or void if overload resolution applied to that expression does not find a usable function.
The return value V of type R of the defaulted three-way comparison operator function with parameters x and y of the same type is determined by comparing corresponding elements and in the expanded lists of subobjects for x and y (in increasing index order) until the first index i where the synthesized three-way comparison of type R between and yields a result value where , contextually converted to bool, yields true; V is .
If no such index exists, V is static_­cast<R>(std​::​strong_­ordering​::​equal).
The common comparison type U of a possibly-empty list of n types , , , is defined as follows: