SKILL

cpp-coding-standards

C++ coding standards based on the C++ Core Guidelines (isocpp.github.io). Use when writing, reviewing, or refactoring C++ code to enforce modern, safe, and idiomatic practices.

Machine translation
Read the original Chinese text

基于C++核心指南(isocpp.github.io)的C++编码标准。在编写、审查或重构C++代码时使用,以强制实施现代、安全和惯用的实践。

Target: Software development & testing. Automatically collected · unverified.

Excerpt from the author’s documentation

Extracted from a fixed version of SKILL.md in its original language. This is the author’s documentation; installation, compatibility and runtime results have not been verified by this site.

Read the original Chinese text

Topics in the source

  • C++ 编码标准(C++ 核心准则)
  • 何时使用
  • 何时不应使用
  • 贯穿性原则
  • 哲学与接口 (P.\, I.\)
  • 关键规则
  • 应该做
  • 不应该做

源自 C++ 核心准则 的现代 C++(C++17/20/23)综合编码标准。强制执行类型安全、资源安全、不变性和清晰性。 编写新的 C++ 代码(类、函数、模板) 审查或重构现有的 C++ 代码 在 C++ 项目中做出架构决策 在 C++ 代码库中强制执行一致的风格 在语言特性之间做出选择(例如,enum 对比 enum class,原始指针对比智能指针) 非 C++ 项目 无法采用现代 C++ 特性的遗留 C 代码库 特定准则与硬件限制冲突的嵌入式/裸机环境(选择性适配) 这些主题在整个准则中反复出现,并构成了基础: 1. 处处使用 RAII (P.8, R.1, E.6, CP.20):将资源生命周期绑定到对象生命周期 2. 默认为不可变性 (P.10, Con.1-5, ES.25):从 const/constexpr 开始;可变性是例外 3. 类型安全 (P.4, I.4, ES.46-49, Enum.3):使用类型系统在编译时防止错误 4. 表达意图 (P.3, F.1, NL.1-2, T.10):名称、类型和概念应传达目的 5. 最小化复杂性 (F.2-3, ES.5, Per.4-5):简单的代码就是正确的代码 6. 值语义优于指针语义 (C.10, R.3-5, F.20, CP.31):优先按值返回和作用域对象 | 规则 | 摘要 | |------|---------| | P.1 | 直接在代码中表达想法 | | P.3 | 表达意图 | | P.4 | 理想情况下,程序应是静态类型安全的 | | P.5 | 优先编译时检查而非运行时检查 | | P.8 | 不要泄漏任何资源 | | P.10 | 优先不可变数据而非可变数据 | | I.1 | 使接口明确 | | I.2 | 避免非 const 全局变量 | | I.4 | 使接口精确且强类型化 | | I.11 | 切勿通过原始指针或引用转移所有权 | | I.23 | 保持函数参数数量少 | | 规则 | 摘要 | |------|---------| | F.1 | 将有意义的操作打包为精心命名的函数 | | F.2 | 函数应执行单一逻辑操作 | | F.3 | 保持函数简短简单 | | F.4 | 如果函数可能在编译时求值,则将其声明为 constexpr | | F.6 | 如果你的函数绝不能抛出异常,则将其声明为 noexcept | | F.8 | 优先纯函数 | | F.16 | 对于 "输入" 参数,按值传递廉价可复制类型,其他类型通过 const& 传递 | | F.20 | 对于 "输出" 值,优先返回值而非输出参数 | | F.21 | 要返回多个 "输出" 值,优先返回结构体 | | F.43 | 切勿返回指向局部对象的指针或引用 | 从函数返回 T&

This is an excerpt. Refer to the complete source and its current requirements.

Source repository
affaan-m/ECC
Source file
docs/zh-CN/skills/cpp-coding-standards/SKILL.md
Fixed revision
d2ef2680594f9a17526a6e1a2e18b3d242c5d17b
Read the complete original documentation ↗

Requirements

  • Only the author’s Skill metadata is included. Read the full instructions to check dependencies, licensing and conditions of use.

A small first task

先阅读原作者说明,再决定是否在自己的 AI 工具中使用。

Instructions for your AI tool

Author documentation is not live verification by this site. Without evidence, we do not mark a resource as compatible, safe or free.

Sources and evidence

This record was collected automatically. Its documentation, suitability and runtime behavior have not been manually verified.

Author: affaan-m/ECC · original repository metadata. Documentation review: Not reviewed. Last source check: 2026-11-09T14:01:50.270Z.

Categories are inferred from names, descriptions and paths. They do not establish compatibility.

License and attribution

MIT. Third-party content and copyright remain with their authors. Refer to the original license and terms.

Original license ↗

Synchronization, copying and user-reported success do not mark a resource as runtime-tested.

Limitations and notes

  • Collecting metadata does not mean this site has installed, adapted, runtime-tested or security-reviewed the resource.