*This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21
Core Issues List revision 115c.
See http://www.open-std.org/jtc1/sc22/wg21/ for the official
list.*

2024-09-25

#### 2432.
Return types for defaulted `<=>`

**Section: **11.10.3 [class.spaceship]
**Status: **C++20
**Submitter: **Richard Smith
**Date: **2019-08-14

[Adopted as a DR at the November, 2019 meeting.]

It is unclear what the constraints are on the type R. We
define the "synthesized three-way comparison for comparison
category type R", but it's defined in such a way that it
works for an arbitrary type R, and the uses of it do not
impose a constraint that R is a comparison category
type. Should it be permissible to default
an `operator<=>` with some other return type,
so long as the construction described in
11.10.3 [class.spaceship] works (specifically, so long as
all subobjects have `operator<=>`s that can be
converted to the specified return type)?

**Proposed resolution (September, 2019)**

Change 11.10.3 [class.spaceship] paragraphs 1-3, changing the
running text of paragraph 2 to into a bulleted list, as follows:

The *synthesized three-way comparison*
~~for comparison category~~ of
type `R` (17.11.2 [cmp.categories]) of
glvalues `a` and `b`...

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 `R`_{i} be
the type of the expression `x`_{i}
`<=> x`_{i}~~ is denoted
by ~~`R`_{i}. If
, or `void` if overload resolution ~~as~~
applied to `x`_{i}
`<=> x`_{i}
that expression does not find a usable
function~~, then ~~`R`_{i}
is `void`.

If ~~the declared return type of a
defaulted three-way comparison operator function~~
`R` is `auto`, then the return type
is deduced as the common comparison type (see below)
of `R`_{0},
`R`_{1},
..., `R`_{n-1}. 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
Otherwise, if the synthesized three-way
comparison ~~for comparison category~~
of type `R` between any
objects `x`_{i}
and `x`_{i} is not defined or would be
ill-formed, the operator function is defined as deleted.

...until the first index *i* where the synthesized
three-way comparison ~~for comparison category~~
of type `R`
between `x`_{i}
and `y`_{i} yields...