Cpp Coding Standards

affaan-m/ECC/docs/ja-JP/skills/cpp-coding-standards

by affaan-mef648e01899ba3e8dc6371642deaaf64b4477775No license275K starsListed Oct 9, 2026Updated Oct 9, 2026Repository updated 4 days ago

C++コアガイドラインに基づくC++コーディング標準(isocpp.github.io)。現代的で安全で慣用的なプラクティスを強制するためにC++コードを書き、レビュー、またはリファクタリングする場合に使用します。

Instructions onlySoftware Development
AI-generated overview

Provides a modern C++ coding standard derived from the C++ Core Guidelines for writing, reviewing, and refactoring C++ code.

What it does
This skill supplies a comprehensive C++ (C++17/20/23) coding standard based on the C++ Core Guidelines, emphasizing type safety, resource safety, immutability, and clarity. It lists cross-cutting principles such as RAII, immutability by default, and value versus pointer semantics, plus a table of key rules like P.1, P.3, P.4, P.5, P.8, P.10, I.1, I.2, and I.4. It also covers smart pointer and ownership guidance, including std::unique_ptr, std::shared_ptr, and std::weak_ptr. It is an instructions-only reference with no scripts or generated artifacts.
When to use it
Use it when writing new C++ code such as classes, functions, or templates, or when reviewing and refactoring existing C++ code. It also fits making architecture decisions in C++ projects, enforcing a consistent style across a codebase, and choosing between language features like enum versus enum class or raw pointers versus smart pointers.
Requirements
No tools, packages, runtimes, credentials, or network access are required; it is instructions only and ships no scripts.

C++コーディング標準(C++コアガイドライン)

C++コアガイドラインから派生した最新のC++(C++17/20/23)の包括的なコーディング標準。タイプセーフティ、リソースセーフティ、不変性、明確性を強制します。

使用時期

  • 新しいC++コードを書く(クラス、関数、テンプレート)
  • 既存のC++コードをレビューまたはリファクタリング
  • C++プロジェクトでアーキテクチャ決定を行う
  • C++コードベース全体で一貫性のあるスタイルを実施
  • 言語機能の選択(例:enum vs enum class、生ポインタ対スマートポインタ)

クロスカッティング原則

これらのテーマはガイドライン全体に繰り返され、基礎を形成:

  1. 至るところにRAII:リソースライフタイムをオブジェクトライフタイムにバインド
  2. デフォルトで不変性:const/constexprで開始;変更可能性は例外
  3. タイプセーフティ:型システムを使用してコンパイル時にエラーを防止
  4. 意図を表現:名前、タイプ、概念は目的を伝える必要があります
  5. 複雑性を最小化:シンプルなコードが正しいコード
  6. 値セマンティクス対ポインタセマンティクス:値で返すか、スコープ付きオブジェクトを好む

主要なルール

RuleSummary
P.1コード内のアイデアを直接表現
P.3意図を表現
P.4理想的には、プログラムは静的にタイプセーフである必要があります
P.5ランタイムチェックに対するコンパイル時チェック
P.8リソースをリークしない
P.10変更可能なデータより不変データを好む
I.1インターフェースを明示的にする
I.2非const グローバル変数を避ける
I.4インターフェースを正確にし、強く型付けされたものにする

スマートポインタと所有権

現代的なC++では、生ポインタの代わりにスマートポインタを使用:

  • std::unique_ptr<T> 単一所有者向け
  • std::shared_ptr<T> 共有所有権向け
  • std::weak_ptr<T> 循環参照を回避するため

Source and attribution

Source:affaan-m/ECCindocs/ja-JP/skills/cpp-coding-standardsat commitef648e0

License: No license

Content belongs to its original authors. SourceWeft indexes it from a public repository.

Report or request removal