Files
affaan-m--everything-claude…/docs/ja-JP/skills/cpp-coding-standards/SKILL.md
T
wehub-resource-sync d48cda4081
CI / Test (ubuntu-latest, Node 18.x, bun) (push) Failing after 15m1s
CI / Test (ubuntu-latest, Node 18.x, npm) (push) Failing after 15m1s
CI / Test (ubuntu-latest, Node 18.x, pnpm) (push) Failing after 15m1s
CI / Test (ubuntu-latest, Node 18.x, yarn) (push) Failing after 15m1s
CI / Test (ubuntu-latest, Node 20.x, bun) (push) Failing after 17m13s
CI / Test (ubuntu-latest, Node 20.x, npm) (push) Failing after 18m42s
CI / Test (ubuntu-latest, Node 20.x, pnpm) (push) Failing after 15m0s
CI / Test (ubuntu-latest, Node 20.x, yarn) (push) Failing after 49m44s
CI / Test (ubuntu-latest, Node 22.x, bun) (push) Failing after 51m55s
CI / Test (ubuntu-latest, Node 22.x, pnpm) (push) Failing after 21m57s
CI / Test (ubuntu-latest, Node 22.x, npm) (push) Failing after 37m39s
CI / Test (ubuntu-latest, Node 22.x, yarn) (push) Failing after 34m7s
CI / Validate Components (push) Failing after 37m15s
CI / Python Tests (push) Failing after 10m1s
CI / Security Scan (push) Failing after 10m1s
CI / Lint (push) Failing after 17m12s
CI / Coverage (push) Failing after 20m19s
CI / Test (macos-latest, Node 18.x, bun) (push) Has been cancelled
CI / Test (macos-latest, Node 18.x, npm) (push) Has been cancelled
CI / Test (macos-latest, Node 18.x, pnpm) (push) Has been cancelled
CI / Test (macos-latest, Node 18.x, yarn) (push) Has been cancelled
CI / Test (windows-latest, Node 18.x, npm) (push) Has been cancelled
CI / Test (windows-latest, Node 18.x, pnpm) (push) Has been cancelled
CI / Test (windows-latest, Node 18.x, yarn) (push) Has been cancelled
CI / Test (macos-latest, Node 20.x, bun) (push) Has been cancelled
CI / Test (macos-latest, Node 20.x, npm) (push) Has been cancelled
CI / Test (macos-latest, Node 20.x, pnpm) (push) Has been cancelled
CI / Test (macos-latest, Node 20.x, yarn) (push) Has been cancelled
CI / Test (windows-latest, Node 20.x, npm) (push) Has been cancelled
CI / Test (windows-latest, Node 20.x, pnpm) (push) Has been cancelled
CI / Test (windows-latest, Node 20.x, yarn) (push) Has been cancelled
CI / Test (macos-latest, Node 22.x, bun) (push) Has been cancelled
CI / Test (macos-latest, Node 22.x, npm) (push) Has been cancelled
CI / Test (macos-latest, Node 22.x, pnpm) (push) Has been cancelled
CI / Test (macos-latest, Node 22.x, yarn) (push) Has been cancelled
CI / Test (windows-latest, Node 22.x, npm) (push) Has been cancelled
CI / Test (windows-latest, Node 22.x, pnpm) (push) Has been cancelled
CI / Test (windows-latest, Node 22.x, yarn) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 11:55:55 +08:00

50 lines
2.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
name: cpp-coding-standards
description: C++コアガイドラインに基づくC++コーディング標準(isocpp.github.io)。現代的で安全で慣用的なプラクティスを強制するためにC++コードを書き、レビュー、またはリファクタリングする場合に使用します。
origin: ECC
---
# 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. **値セマンティクス対ポインタセマンティクス**:値で返すか、スコープ付きオブジェクトを好む
## 主要なルール
| Rule | Summary |
|------|---------|
| **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>` 循環参照を回避するため