Closed BenHetherington closed 2 years ago
nice, i have exactly this problem and cannot compile with clang because of this
I believe I have run into this exact problem. I came up with a workaround for my particular case (just operator==), but I suspect this patch is a much more complete solution.
I have encountered the same problem and would be very happy if this solution is accepted. The pull request has been ready for half a year now. What is keeping you from merging it @joboccara?
When C++20 is enabled, this fixes a warning when compiling
==
or!=
under Clang, and an error when compiling!=
under MSVC or GCC. (See https://godbolt.org/z/Th4WE4EdP for an example of this error and warning.)C++20 can now rewrite comparison operators, potentially swapping arguments or rewriting missing operators in terms of other operators. As
NamedType
s inheriting from theComparable
skill fulfil both sides of the comparisons, this can lead to ambiguities as to which comparison operator should be selected, once swapped arguments are considered.This PR fixes this ambiguity by making the comparisons take two
Comparable<T>
s instead of aComparable<T>
and aT
.If there's a reason for this asymmetry, then I'm happy for a different solution to be used here. I've also effectively reverted bcc4051 (as this seemed to be part of the reason why MSVC and GCC considered
!=
ambiguous enough to be an error), so if this reintroduces a warning, then also let me know.