C.65: clarify pointer move example with comments (issue #1892)

This commit is contained in:
Sergey Zubkov
2022-10-07 09:22:00 -04:00
parent 0b22b82159
commit 65aae3ede6

View File

@@ -6387,8 +6387,8 @@ Here is a way to move a pointer without a test (imagine it as code in the implem
// move from other.ptr to this->ptr // move from other.ptr to this->ptr
T* temp = other.ptr; T* temp = other.ptr;
other.ptr = nullptr; other.ptr = nullptr;
delete ptr; delete ptr; // in self-move, this->ptr is also null; delete is a no-op
ptr = temp; ptr = temp; // in self-move, the original ptr is restored
##### Enforcement ##### Enforcement