Clang C++20 compatibility: made operator== and operator!= friend functions#31
Clang C++20 compatibility: made operator== and operator!= friend functions#31JPenuchot wants to merge 2 commits intopeter-winter:masterfrom
Conversation
|
What about gcc? Is it really somthing the standard added in c++20? Declaring == operator as a member was a common thing, this would break a lot of code. Can you point me to some article explaining the change? |
I didn't try anything yet with gcc as it doesn't support constexpr virtual destructors and I'm using them. I may be able to find a minimal example to reproduce the error I'm trying to fix.
https://en.cppreference.com/w/cpp/language/default_comparisons |
|
But I'm not using default comparisons here. These are just custom comparisons. |
|
Any progress on this issue? |
|
Not yet, I'm busy with non-literal type compatibility at the moment. I will spend more time on that issue later and try to find better explanations. |
|
I found these issues on the clang bug tracker: https://bugs.llvm.org/show_bug.cgi?id=43765 So it might just be a Clang issue as you said. So far turning the |
…ang C++20 compatibility
…enerate in C++20 mode
Here is an example error message prior to this fix which I got using Clang 13.0.0 with
-std=c++20:The way I understand it from explanations by @jfalcou (who suggested this fix to me) is that C++20 generates a
friend operator==by default which is ambiguous with the one provided by ctpg.This commit fixes that by providing
operator==as a friend function rather than a member function, therefore avoiding any ambiguity.friend operator!=is also provided after this commit.Correct me if I'm wrong however.
Regards,
Jules