And the bad part is that whether GetMyObj() was called is undefined.
"Ulrich Eckhardt" <eckhardt@satorlaser.com> wrote in message
news:n7gju4-03j.ln1@satorlaser.homedns.org
In order to perform the assignment, you first need both sides, i.e.
the right-hand side is evaluated before performing the assignment.
Also consider the case that something on the right hand side throws an
exception. In that case, the left-hand side is not touched.
That's not completely true. Consider:
MyObj& GetMyObj();
GetMyObj() = o.DoSomething();
If DoSomething throws, it is true that the assignment won't be executed -
but GetMyObj may already have been called by that time, possibly producing
side effects. So the left hand side may not remain entirely untouched.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925