Clarify that marking certain member variables const can hinder performance

オープン
#147 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
45/100
issue の種類
ドキュメント
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
cpp
領域
documentation

調査の方向性

まず 03-Style ドキュメントを見つけ、変更されないメンバー変数を const としてマークすることについて引用されているガイダンスを確認します。const の正しさとコンテナの移動との間にある、文書化されたトレードオフを明確にします。また、issue で説明されている private フィールド用 getter の選択肢も含め、その後、レンダリングされたドキュメントを確認します。

索引モデルが issue の本文から書いたものです。

説明

In the 03-Style document, I read the following sentence:

If the member variable is not expected to change after the initialization, then mark it const.

However, we know that if, for example, we mark a container as const, we prevent it from being moved, possibly hindering performance. Marking fields as const is useful to enforce invariants; however, it "interferes" with performance. If both const correctness and performance are important, one could leave the field non-const, make it private and define a field getter.

主要言語
言語のデータがありません
スター
8.9k
フォーク
903
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

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

cpp-best-practices/cppbestpractices のほかの issue

cpp-best-practices/cppbestpractices の issue をすべて見る

似ている issue

Documentation の issue をもっと見る

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

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