Quantcast
Channel: User HolyBlackCat - Stack Overflow
Viewing all articles
Browse latest Browse all 946

Answer by HolyBlackCat for Different behavior reason when overloading + and == operators

$
0
0

Comparison operators got an upgrade in C++20 (along with introduction of <=>), which among other things makes == symmetric, lets you skip defining != (a != b behaves as !(a == b) when there's no custom !=), and so on.

This wasn't done for +. At least one reason is that (unlike ==) it's often not symmetric (e.g. for std::string).


Viewing all articles
Browse latest Browse all 946

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>