Re: How to check for assignment to self?
"Jerry Coffin" <jcoffin@taeus.com> schrieb im Newsbeitrag
news:MPG.21aad6f6fa642df7989aa7@news.sunsite.dk...
In article <roy-F60C42.19490318112007@news.panix.com>, roy@panix.com
says...
In article <G9ydnfGRdKgQ1d3anZ2dnUVZ8uWdnZ2d@eclipse.net.uk>,
Francis Glassborow <francis.glassborow@btinternet.com> wrote:
Either way, the basic idea is pretty simple: we never modify the
existing target item until we're sure we can do so with no chance of an
exception occurring when we do it. Anyway, we either get an exception
while we're creating the copy (in which case, the original item remains
untouched) or else no exception occurs at all, in which case our
assignment succeeds in its entirety.
I like that idiom, as it basically implements the copy assignment operator
in terms of the copy constructor, thus also reducing code duplication.
--
Matthias Hofmann
Anvil-Soft, CEO
http://www.anvil-soft.com - The Creators of Toilet Tycoon
http://www.anvil-soft.de - Die Macher des Klomanagers
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]