Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualiMalc

Posted 07 April 2013 - 01:27 PM

Actually, "typicaly" one would use the copy-and-swap idiom, because it is both simpler and exception safe, and does not have any problem with self-assignment.

What is warning you about self-assignment probably only applies in the particular scenario you were reading about. In general there is no reason to. Any assignment operator that must check for self-assignment is not exception safe. See the GotW archives.

#1iMalc

Posted 07 April 2013 - 01:26 PM

Actually, "typicaly" one would use the copy-and-swap idiom, because it is both simpler and exception safe, and does not have any problem with self-assignment.

What is warning you about self-assignment probably only applies in the particular scenario you were reading about. In general there is no reason to. Any assignment operator that must check for self-assignment is not exception safe. See the GotW archives (www.GotW.ca/GotW).

PARTNERS