From 402815345e3ffe8c2f201380c6aef8315d238f0d Mon Sep 17 00:00:00 2001 From: Herb Sutter Date: Thu, 10 Jun 2021 11:36:01 -0700 Subject: [PATCH] Added suggestion to use a pointer member instead of a reference; closes #1783 --- CppCoreGuidelines.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CppCoreGuidelines.md b/CppCoreGuidelines.md index 01fe26b..fa3e088 100644 --- a/CppCoreGuidelines.md +++ b/CppCoreGuidelines.md @@ -4593,6 +4593,12 @@ They are not useful, and make types difficult to use by making them either uncop // ... }; +The `const` and `&` data members make this class "only-sort-of-copyable" -- copy-constructible but not copy-assignable. + +##### Note + +If you need a member to point to something, use a pointer (raw or smart, and `gsl::not_null` if it should not be null) instead of a reference. + ##### Enforcement Flag a data member that is `const`, `&`, or `&&`.