The copy swap idiom in C++ can be used to simplify the implementation of the assignment operator by used the copy constructor to generate a local copy and swapping it with the current object.
The copy swap idiom in C++ can be used to simplify the implementation of the assignment operator by used the copy constructor to generate a local copy and swapping it with the current object.
Use this tag for questions related to the copy and swap idiom.
For more detail, see also this Stackoverflow question.