Title
Deduced return type of a deleted three-way comparison operator function
Status
open
Section
11.10.3 [class.spaceship]
Submitter
Arthur O'Dwyer

Created on 2026-06-29.00:00:00 last changed 2 days ago

Messages

Date: 2026-06-29.19:53:33

Possible resolution:

Change in 11.10.3 [class.spaceship] bullet 2.1 as follows:

Let R be the declared return type of a defaulted three-way comparison operator function, and let xi be the elements of the expanded list of subobjects for an object x of type C.
  • If R is auto, then let cv i Ri be the type of the expression xi <=> xi . The operator function is defined as deleted if that expression is not usable or if Ri is not a comparison category type (17.12.2.1 [cmp.categories.pre]) for any i. The Otherwise, the return type is deduced as the common comparison type (see below) of R0, R1, ..., Rn-1.
  • ...
Date: 2026-06-29.00:00:00

Consider:

  struct A { friend int operator<=>(A,A); };
  struct B { A a; friend auto operator<=>(const B&) const = default; };
  using Q = [: return_type_of(^^B::operator<=>) :];

What is the type Q?

Traditionally, CWG had the viewpoint that querying properties of deleted functions (e.g. triviality) should be impossible or ill-formed.

History
Date User Action Args
2026-06-29 19:53:33adminsetmessages: + msg8621
2026-06-29 00:00:00admincreate