NL.16 is ambiguous
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 75/100
- Issue 类型
- 文档
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- cpp, markdown
调研方向
阅读 NL.16 指南以及 issue #962、#977 和 #980 中引用的讨论,然后查看 commit edbfc3b 中先前的澄清。该 issue 提议添加两个代码示例中的一个,以明确首选顺序。完成标准是 NL.16 清楚说明首选哪种顺序。
由索引模型根据 Issue 内容生成。
描述
Previously discussed in #962, #977, #980.
The recommendation according to the guideline is:
When declaring a class use the following order
- types: classes, enums, and aliases (
using)- constructors, assignments, destructor
- functions
- data
Use the
publicbeforeprotectedbeforeprivateorder.
These are two different dimensions, kind (types, special member functions, functions, data) and access (public, protected, private), without clearly stating which takes priority.
Discussion from editors on previous issues (i.e. comment which appears to reference comment) seems to indicate that access takes priority over kind:
class X {
public:
void f();
int i;
private:
void g();
int j;
};
At the same time, NL.16 was updated with the goal of clarifying, adding the text:
Sometimes, the default order of members conflicts with a desire to separate the public interface from implementation details. In such cases, private types and functions can be placed with private data.
Here, it's stated that "a desire to separate the public interface from implementation details" (i.e. grouping every kind of public member together, as in the above snippet) is in conflict with "the default order of members." This seems to indicate that this is not the default, which would mean that the default order of members is instead to prioritize kind over access:
class X {
public:
void f();
private:
void g();
public:
int i;
private:
int j;
};
So, the guideline as written does not clearly explain which dimension takes priority, and searching through the repository history shows that when this came up previously, there were two simultaneous but contradictory resolutions.
Suggestion: Provide one of the two above snippets as an unambiguous example of NL.16 showing the preferred first choice (when you have no constraints or better ideas).
- 主要语言
- CSS
- 星标
- 45.5k
- 派生
- 5.6k
- 平均合并
- 6 分钟
- 30 天内合并 PR
- 1
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
isocpp/CppCoreGuidelines 的其他 Issue
-
难度 1/5 1-3 小时 新手友好度 78/100
isocpp/CppCoreGuidelines#2345 ·
-
Use short #s-xxx as ref, not long like #sl-the-standard-library or #gsl-guidelines-support-library未关闭
难度 2/5 1-3 小时 新手友好度 64/100
isocpp/CppCoreGuidelines#2340 ·
-
难度 2/5 1-3 小时 新手友好度 68/100
isocpp/CppCoreGuidelines#2205 · 8 条评论 ·
-
难度 1/5 1 小时以内 新手友好度 64/100
isocpp/CppCoreGuidelines#1649 · 3 条评论 ·
-
难度 5/5 一周以上 新手友好度 35/100
isocpp/CppCoreGuidelines#2342 · 2 条评论 ·
查看 isocpp/CppCoreGuidelines 的全部 Issue
相似的 Issue
-
marketing
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
agent:WSL code-review documentation performance pri:medium tooling
难度 1/5 1 小时以内 新手友好度 82/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 77/100
Feyisara2108/stellargive#1370 ·
维护者通常 1 天内回复
-
documentation enhancement good first issue
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
documentation tool triaged
难度 2/5 1-3 小时 新手友好度 73/100
can1357/oh-my-pi#19608 · 2 条评论 ·
维护者通常 1 天内回复