diff --git a/CppCoreGuidelines.md b/CppCoreGuidelines.md index fa10073..3679504 100644 --- a/CppCoreGuidelines.md +++ b/CppCoreGuidelines.md @@ -4420,6 +4420,7 @@ Concrete type rule summary: * [C.10: Prefer concrete types over class hierarchies](#Rc-concrete) * [C.11: Make concrete types regular](#Rc-regular) +* [C.12: Don't make data members `const` or references](#Rc-constref) ### C.10: Prefer concrete types over class hierarchies @@ -4509,6 +4510,27 @@ Often, such types are referred to as "move-only types". ??? + +### C.12: Don't make data members `const` or references + +##### Reason + +They are not useful, and make types difficult to use by making them either uncopyable or partially uncopyable for subtle reasons. + +##### Example; bad + + class bad { + const int i; // bad + string& s; // bad + // ... + }; + +##### Enforcement + +Flag a data member that is `const`, `&`, or `&&`. + + + ## C.ctor: Constructors, assignments, and destructors These functions control the lifecycle of objects: creation, copy, move, and destruction.