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

Created on 2021-09-06.00:00:00 last changed 3 days ago


Date: 2021-09-15.00:00:00

[ 2021-09-20; Reflector poll ]

Set priority to 3 after reflector poll.

Date: 2021-09-06.00:00:00

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)

Date User Action Args
2021-09-20 11:22:03adminsetmessages: + msg12053
2021-09-06 00:00:00admincreate