[libcxx-commits] [libcxx] [libc++] Further constrain comparison against foo_ordering types (PR #127311)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Feb 19 11:02:32 PST 2025
ldionne wrote:
Hmm, this doesn't seem to work (seen in CI):
```
In file included from <...>/libcxx/test/std/utilities/function.objects/refwrap/refwrap.comparissons/compare.three_way.refwrap.const_ref.pass.cpp:23:
<...>/libcxx/test/support/test_comparisons.h:167:23: error: use of overloaded operator '==' is ambiguous (with operand types 'std::strong_ordering' and 'std::weak_ordering')
167 | return (t1 <=> t2 == order) && testComparisonsComplete(t1, t2, equal, less, greater);
| ~~~~~~~~~ ^ ~~~~~
<...>/libcxx/test/std/utilities/function.objects/refwrap/refwrap.comparissons/compare.three_way.refwrap.const_ref.pass.cpp:51:12: note: in instantiation of function template specialization 'testOrder<std::weak_ordering, std::reference_wrapper<int>, int>' requested here
51 | assert(testOrder(rw1, t, Order::equivalent));
| ^
<...>/libcxx/test/std/utilities/function.objects/refwrap/refwrap.comparissons/compare.three_way.refwrap.const_ref.pass.cpp:73:3: note: in instantiation of function template specialization 'test<int, std::weak_ordering>' requested here
73 | test<int, std::weak_ordering>();
| ^
<...>/build/generic-modules/libcxx/test-suite-install/include/c++/v1/__compare/ordering.h:221:47: note: candidate function
221 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(strong_ordering __v, _CmpUnspecifiedParam) noexcept {
| ^
<...>/build/generic-modules/libcxx/test-suite-install/include/c++/v1/__compare/ordering.h:143:47: note: candidate function
143 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(weak_ordering, weak_ordering) noexcept = default;
| ^
<...>/build/generic-modules/libcxx/test-suite-install/include/c++/v1/__compare/ordering.h:145:47: note: candidate function (with reversed parameter order)
145 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(weak_ordering __v, _CmpUnspecifiedParam) noexcept {
| ^
```
I think that's because `= delete` on the `_CmpUnspecifiedParam` constructors is actually different from not providing constructors at all -- it defines them but defines them as deleted, which means they are still candidates for overload resolution. @zygoloid Given this, I'm not certain how to move forward with this patch. I'm personally not very inconvenienced by the fact that we accept `x <=> y == something_constexpr`, so I'd be tempted to just leave it as-is unless you have a suggestion for moving forward.
https://github.com/llvm/llvm-project/pull/127311
More information about the libcxx-commits
mailing list