mirror of
https://github.com/isocpp/CppCoreGuidelines.git
synced 2025-12-17 04:44:34 +03:00
C.65: clarify pointer move example with comments (issue #1892)
This commit is contained in:
@@ -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
|
||||
T* temp = other.ptr;
|
||||
other.ptr = nullptr;
|
||||
delete ptr;
|
||||
ptr = temp;
|
||||
delete ptr; // in self-move, this->ptr is also null; delete is a no-op
|
||||
ptr = temp; // in self-move, the original ptr is restored
|
||||
|
||||
##### Enforcement
|
||||
|
||||
|
||||
Reference in New Issue
Block a user