Skip to content

Commit 65aae3e

Browse files
committed
C.65: clarify pointer move example with comments (issue #1892)
1 parent 0b22b82 commit 65aae3e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

CppCoreGuidelines.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -6387,8 +6387,8 @@ Here is a way to move a pointer without a test (imagine it as code in the implem
63876387
// move from other.ptr to this->ptr
63886388
T* temp = other.ptr;
63896389
other.ptr = nullptr;
6390-
delete ptr;
6391-
ptr = temp;
6390+
delete ptr; // in self-move, this->ptr is also null; delete is a no-op
6391+
ptr = temp; // in self-move, the original ptr is restored
63926392

63936393
##### Enforcement
63946394

0 commit comments

Comments
 (0)