I noticed C++ has operator overloading syntax with just the operator names:
T& operator +(T& lhs, T& rhs) { return /* ... */;}
However, there are 2 distinct operators that are both ++
and --
. One being a suffix and one being a prefix. C++ syntax has no way to distinguish them with the syntax, so instead one of them uses an unused int
parameter. But this seems ungraceful.
What would be a good alternative syntax for operator overloading that could unambiguously distinguish unary +
with binary +
and also distinguish ++x
from x++
without hacks such as unused parameters?