We delve into how C++20 introduced changes to object comparisons, leading to unexpected behavior and the need for matching operator!= declarations.
DR20 - The Equality Operator You Are Looking For
by Sandor Dargo
From the article:
When I see DR, I immediately think about Disaster Recovery. That’s due to my first corporate job where I worked as a Database Administrator and we had regular exercises to simulate events when datacenters would be unavailable.
When you see DR in the title of a C++ proposal, it’s not about a disaster, it’s more about a bug. DR stands for defect report. But the paper itself is usually not about reporting that there is a problem - that has been already done -, but more about proposing a solution.
What’s more important is that defect reports are not becoming part of the latest standard, they retrospectively change the one that introduced the defect.
A defect of C++20’s equality operator
P2468R2 is addressing a problem that was introduced by C++20. C++20 brought us the spaceship operator (
operator<=>
), but it further changed the logic of object comparisons. It changed the meaning of==
and!=
and how overload resolution applies to them.
Add a Comment
Comments are closed.