Let foo
be a struct or class with a copy assignment operator:
struct foo {
foo &operator=(const foo &); // or with some other return type?
};
Is there ever a sensible reason to return anything other than *this
from the operator=()
? Using it for something unrelated to assignment doesn't qualify as sensible.
The example from the standard is std::atomic
. It returns the assigned value. If it returned reference, then reading through it might yield different result.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With