From 7143050ef691804a1b6b9514577efc4c4c8820f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20K=C3=B6ppe?= Date: Sat, 3 Oct 2015 16:09:03 +0100 Subject: [PATCH] [GSL.view] Make wording around null pointers and null references more precise. --- CppCoreGuidelines.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/CppCoreGuidelines.md b/CppCoreGuidelines.md index dd80795..268b5c2 100644 --- a/CppCoreGuidelines.md +++ b/CppCoreGuidelines.md @@ -12171,23 +12171,23 @@ References are never owners. The names are mostly ISO standard-library style (lower case and underscore): -* `T*` // The `T*` is not an owner, may be `nullptr` (Assumed to be pointing to a single element) -* `char*` // A C-style string (a zero-terminated array of characters); can be `nullptr` -* `const char*` // A C-style string; can be `nullptr` -* `T&` // The `T&` is not an owner, may not be `&(T&)*nullptr` (language rule) +* `T*` // The `T*` is not an owner, may be null; assumed to be pointing to a single element. +* `char*` // A C-style string (a zero-terminated array of characters); may be null. +* `const char*` // A C-style string; may be null. +* `T&` // The `T&` is not an owner, must not be `*static_cast(nullptr)` (language rule; there are no "null references"). The "raw-pointer" notation (e.g. `int*`) is assumed to have its most common meaning; that is, a pointer points to an object, but does not own it. Owners should be converted to resource handles (e.g., `unique_ptr` or `vector`) or marked `owner` -* `owner` // a `T*`that owns the object pointed/referred to; can be `nullptr` -* `owner` // a `T&` that owns the object pointed/referred to +* `owner` // a `T*`that owns the object pointed/referred to; may be `nullptr`. +* `owner` // a `T&` that owns the object pointed/referred to. `owner` is used to mark owning pointers in code that cannot be upgraded to use proper resource handles. -Reasons for that include +Reasons for that include: -* cost of conversion -* the pointer is used with an ABI -* the pointer is part of the implementation of a resource handle. +* Cost of conversion. +* The pointer is used with an ABI. +* The pointer is part of the implementation of a resource handle. An `owner` differs from a resource handle for a `T` by still requiring an explicit `delete`.