Hi
I am implementing operator overloading in the context of
the C language.
I would like to have your opinion about this:
Would it be a good idea to assume that the
operator != could be synthethized from
! a == b (operator_equal)
operator >= could be built from ! operator<
operator < could be built from ! operator>=
etc etc.
This would greatly reduce the number of operator
functions that the user needs to implement...
In the same style a == b implies that b == a isn't it?
This means that
int operator==(foo &a,int &b) is the same as
int operator==(int &b,foo &a)
making == and != commutative.
Another step would be to assume commutativity
in the arithmetic operators, what is kind of riskier.
A+B != B+A if you overload the "+" for strings:
"1234" + "5678" --> "12345678", but
"5678" + "1234" --> "56781234"
What guidelines should be sensible to follow?
Thanks in advance for your comments
jacob