With reference to this MSDN article , at the end (Section: Robust Programming) it states,
To prevent resource leaks, always free resources (such as memory, file handles, and sockets) in the move assignment operator.
What will happen if the move assignment is instead implemented as:
MemoryBlock& operator=(MemoryBlock&& other)
{
if (this != &other)
{
std::swap(_data, other._data);
std::swap(_length, other._length);
}
return *this;
}
Wouldn't the "_data" of the rvalue that "other" references be freed when it goes out of scope?