19 Feb
2023
19 Feb
'23
11:08 p.m.
Gavin Lambert wrote:
(Also, can someone explain why x == y <==> y == x is controversial? I have a hard time picturing a use case where you deliberately intend these to be non- commutative, outside of pathological library-fights.)
Why is this "pathological"? If you allow heterogeneous comparisons, who decides the meaning of x == y, the author of x or the author of y? The unspoken convention in C++ is "the left hand decides". Because there needs to be a convention. Why the left hand side? Because (a) it's natural and (b) if you use member operator==, that's what happens.