You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This "construct-and-swap" idiom just requires the definition of a swap function that does a memberwise swap and lets the compiler decide whether to construct the argument using copy semantics or move semantics. There's no need to factor the copy logic out of the constructor.
The text was updated successfully, but these errors were encountered:
Our current assignment operator implementations use this general idiom:
This has a few drawbacks:
The more modern C++ approach is to write an assignment operator like this:
This "construct-and-swap" idiom just requires the definition of a swap function that does a memberwise swap and lets the compiler decide whether to construct the argument using copy semantics or move semantics. There's no need to factor the copy logic out of the constructor.
The text was updated successfully, but these errors were encountered: