NL.16 is ambiguous

オープン 初心者向け
#2,344 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
75/100
issue の種類
ドキュメント
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
cpp, markdown
領域
documentation

調査の方向性

NL.16のガイドラインと、issue #962、#977、#980で参照されている議論を読み、その後、commit edbfc3bにある以前の説明を確認してください。このissueでは、推奨される順序を明確にするため、2つのコード例のうち1つを追加することを提案しています。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 public before protected before private order.

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分
マージ済み PR(30日)
1

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

isocpp/CppCoreGuidelines のほかの issue

isocpp/CppCoreGuidelines の issue をすべて見る

似ている issue

Documentation の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。