page =
url = https://quuxplusone.github.io/blog
arthur o'dwyer – stuff mostly about c++
argument-dependent-lookup c++-style operator-spaceship stl-classic
C++20 introduces new expression-rewriting rules for comparison operators, such that the compiler can rewrite
a < b
as either
(a <=> b) < 0
or
0 < (b <=> a)
, and
a != b
!(a == b)
!(b == a)
. Today, someone asked whether these new rules decrease the attractiveness of the hidden friend idiom for overloaded operators — at least for
, should we just declare it as a member function? The answer is no. Observe ( Godbolt ):