In particular, the correct-correction of prefix operators makes sense to me - it is useful if you want to do further operations on the object.
However, I cannot understand why the postfix operator was created to return by value.
Is this the only convention or is there a good reason why it was designed in this way (for example, the return value does not make sense for the postfix, but makes sense for the prefix)?
Can someone explain?
ANSWER
Thanks to the answers below, it seems that the postfix operator does not have to return by value (in accordance with standards).
However, due to the semantic requirements of the postfix operator (return the original value, and then increase the link to the original value later) in combination with the standard requirement:
Operator overloads are functions, so all side effects must be performed before the function completes.
as David Rodriguez clearly explains below, the split of meaning seems to be a necessary consequence of semantic demands.
In this context, since we are returning a different value (and not the original link, since it will be changed by the closing bracket of the function), returning another value by value seems to make the most sense.
source share