The *synthesized three-way comparison*
for comparison category type R ([cmp.categories])
of glvalues a and b of the same type
is defined as follows:

- If overload resolution for a <=> b results in a usable function ([over.match]), static_cast<R>(a <=> b).
- Otherwise, if overload resolution for a <=> b finds at least one viable candidate, the synthesized three-way comparison is not defined.
- Otherwise, if R is strong_ordering, then
a == b ? strong_ordering::equal : a < b ? strong_ordering::less : strong_ordering::greater

- Otherwise, if R is weak_ordering, then
a == b ? weak_ordering::equivalent : a < b ? weak_ordering::less : weak_ordering::greater

- Otherwise, if R is partial_ordering, then
a == b ? partial_ordering::equivalent : a < b ? partial_ordering::less : b < a ? partial_ordering::greater : partial_ordering::unordered

- Otherwise, if R is strong_equality, then
a == b ? strong_equality::equal : strong_equality::nonequal

- Otherwise, if R is weak_equality, then
a == b ? weak_equality::equivalent : weak_equality::nonequivalent

- Otherwise, the synthesized three-way comparison is not defined.

Given an expanded list of subobjects for an object x of type C,
the type of the expression <=>
is denoted by .

If the declared return type
of a defaulted three-way comparison operator function
is auto,
then the return type is deduced as
the common comparison type (see below) of
, , …, .

If the return type is deduced as void,
the operator function is defined as deleted.

If the declared return type of
a defaulted three-way comparison operator function
is R
and the synthesized three-way comparison
for comparison category type R
between any objects and
is not defined or would be ill-formed,
the operator function is defined as deleted.

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 for comparison category type R
between and
yields a result value where ,
contextually converted to bool, yields true;
V is .

- Otherwise, if at least one is std::weak_equality, or at least one is std::strong_equality and at least one is std::partial_ordering or std::weak_ordering, U is std::weak_equality ([cmp.weakeq]).
- Otherwise, if at least one is std::strong_equality, U is std::strong_equality ([cmp.strongeq]).
- Otherwise, if at least one is std::partial_ordering, U is std::partial_ordering ([cmp.partialord]).