From 65aae3ede6e7e61cc6846d2723e1825d5c582133 Mon Sep 17 00:00:00 2001 From: Sergey Zubkov Date: Fri, 7 Oct 2022 09:22:00 -0400 Subject: [PATCH] C.65: clarify pointer move example with comments (issue #1892) --- CppCoreGuidelines.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CppCoreGuidelines.md b/CppCoreGuidelines.md index 512a227..0c58286 100644 --- a/CppCoreGuidelines.md +++ b/CppCoreGuidelines.md @@ -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