From cbf455407e969240bdda70240bdb6206f690e6ee Mon Sep 17 00:00:00 2001 From: bgloyer <36457894+bgloyer@users.noreply.github.com> Date: Wed, 13 Jul 2022 09:23:14 -0700 Subject: [PATCH] Clean up and add example for C.32 - raw pointers (#1909) * Update CppCoreGuidelines.md * Update CppCoreGuidelines.md * Update isocpp.dic * use snake casing * sake case naming * C 32 comments (#3) * F.16 ("in" parameters): Move Matrix example to F.20 (return values) (#1922) The `Matrix` example and the notes about assignment appear off-topic in rule F.16, as F.16 is specifically about "in" parameters. With help from Sergey Zubkov. * SL.io.50 (Avoid `endl`): Mention string streams (#1920) Explicitly mentioned string streams as `endl` insertions into string streams do actually occur in the wild. With help from Sergey Zubkov. * Extended E.16 to include copy ctor for exception type, closes #1921 * Fix GitHub Actions build warnings, Marker style should be `*` (#1925) * restored reference * Added references to note Co-authored-by: Niels Dekker Co-authored-by: Herb Sutter Co-authored-by: Niels Dekker Co-authored-by: Herb Sutter --- CppCoreGuidelines.md | 13 ++++++++++--- scripts/hunspell/isocpp.dic | 3 +++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CppCoreGuidelines.md b/CppCoreGuidelines.md index eaab74d..fceee69 100644 --- a/CppCoreGuidelines.md +++ b/CppCoreGuidelines.md @@ -4993,12 +4993,19 @@ There is a lot of code that is non-specific about ownership. ##### Example - ??? + class legacy_class + { + foo* m_owning; + bar* m_observer; + } + +The only way to determine ownership may be to dig through the code to look for +allocations. If a pointer or reference is owning, document it as owning. ##### Note -If the `T*` or `T&` is owning, mark it `owning`. If the `T*` is not owning, consider marking it `ptr`. -This will aid documentation and analysis. +Ownership should be clear in new code (and refactored legacy code) according to [R.20](#Rr-owner) for owned +pointers and [R.3](#Rr-ptr) for non-owned pointers. References should never own [R.4](#Rr-ref). ##### Enforcement diff --git a/scripts/hunspell/isocpp.dic b/scripts/hunspell/isocpp.dic index e9d90e5..0b3520d 100644 --- a/scripts/hunspell/isocpp.dic +++ b/scripts/hunspell/isocpp.dic @@ -286,6 +286,7 @@ Lakos Lakos96 Lavavej LCSD05 +legacy_class lifecycle *life-time linearization @@ -301,6 +302,8 @@ lvalues m1 m2 m3 +m_owning; +m_observer; macros2 malloc mallocfree