Reputation: 132128
Suppose I'm writing a class intended not just for my private use, but for others to use as well (e.g. it's exposed in a library I'm writing or modifying). Let's suppose also that it's not a singleton.
Under what conditions would it be wise/useful/prudent to accompany such a class with a swap()
function (a-la-std::swap
, but in the same namespace; as described, for example, here)? And - would they relate to the "rule of five" vs "rule of zero"?
Note: If your answer is valid only with some minimum version of the C++ standard, that's fine, just say so.
Upvotes: 0
Views: 58