3 ms·
Why is checking for self assignment necessary?
by liquidify 8y ago
Why is checking for self assignment necessary?
- banachtarski 8y agoThere are pathological cases where due to layers of abstraction (in a data structure say), an element gets moved to itself. The algorithm is unaware of this but it happens anyways. If you fail to check for self assignment, you will clear the "other" owning pointer/resource and this will result in a leak, as well as resulting in an ill-formed object.