Assignment operator

Assignment operator

Defects in a user-defined assignment operator that mishandles the boundary cases value semantics demand. The canonical one is the missing self-assignment guard: an operator that releases its own resources before copying from the source breaks when source and target are the same object, freeing the data it is about to read — a hazard the copy-and-swap idiom sidesteps by construction.

In this section