3587. std::three_way_comparable_with<T, U, void> can be satisfied but can't be modeled

Section: 17.11.4 [cmp.concept] Status: New Submitter: Jiang An Opened: 2021-09-06 Last modified: 2021-10-23

Priority: 3

View all other issues in [cmp.concept].

View all issues with New status.

Discussion:

Due to the current specification of std::common_comparison_category, compare-as<void, void> is satisfied. And thus given two types T and U with regular ==, !=, <, >, <=, and >= but irregular <=> that has return type void, std::three_way_comparable_with<T, U, void> is satisfied.

However, in this situation std::three_way_comparable_with<T, U, void> can't be modeled, because Cat(t <=> u) == Cat(C(t) <=> C(u)) is ill-formed if Cat is void (see this godbolt link).

I don't think this issue has any impact on meaningful codes, but it seems to be a hole in the current specification.

It seems that compares-as<void, void> should be changed to false. compares-as<NonComparisonCategoryType, void> might need refinement.

(Note: The same problem does not exists for std::three_way_comparable, because std::three_way_comparable<T, void> can be modeled if the <=> on T has "regular" definition or its return type is not a comparison category type, but the return value has "regular" semantics)

[2021-09-20; Reflector poll]

Set priority to 3 after reflector poll.

Proposed resolution: