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

2024-04-18


2437. Conversion of std::strong_ordering in a defaulted operator<=>

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.]

According to 11.10.3 [class.spaceship] paragraph 3,

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 xi and yi 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 xi and yi yields a result value vi where vi != 0, contextually converted to bool, yields true; V is vi converted to R. If no such index exists, V is std::strong_ordering::equal converted to R.

This is meaningless, however, because the kind of conversion is not specified. According to bullet 1.1,

so consistency would suggest that static_cast<R>(std::strong_ordering::equal) is probably the right answer.

Proposed resolution (October, 2019):

Change 11.10.3 [class.spaceship] paragraph 3 as follows:

...If no such index exists, V is static_cast<R>(std::strong_ordering::equal) converted to R.