提交 77b41757 编写于 作者: H Herb Sutter

Added C.12 to discourage `const`/reference data members

Would have been nice to put this after C.9 but item numbers are dense
around here.
上级 4498e078
......@@ -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)
### <a name="Rc-concrete"></a>C.10: Prefer concrete types over class hierarchies
......@@ -4509,6 +4510,27 @@ Often, such types are referred to as "move-only types".
???
### <a name="Rc-constref"></a>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 `&&`.
## <a name="S-ctor"></a>C.ctor: Constructors, assignments, and destructors
These functions control the lifecycle of objects: creation, copy, move, and destruction.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册