@chengzhao-dev/dsh-cpp-workflow 0.7.3 → 0.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +7 -7
- package/README.md +7 -7
- package/lib/client.js +1 -1
- package/lib/comment-policy.js +1 -1
- package/lib/index.js +3 -3
- package/package.json +9 -3
- package/skills/building-cpp/SKILL.md +15 -15
- package/skills/building-cpp/examples/environment.md +4 -3
- package/skills/building-cpp/references/{build-script.md → 01-build-script.md} +4 -3
- package/skills/building-cpp/references/{environment.md → 02-environment.md} +3 -2
- package/skills/building-cpp/steps/01-build.md +2 -2
- package/skills/building-cpp/steps/02-tooling.md +12 -12
- package/skills/building-cpp/steps/03-check.md +5 -5
- package/skills/building-cpp/{project/vscode/02-settings.md → steps/04-vscode.md} +24 -6
- package/skills/developing-cpp/SKILL.md +13 -13
- package/skills/developing-cpp/references/comments/{comment-rules.md → 01-comment-rules.md} +52 -47
- package/skills/developing-cpp/references/comments/{comment-style.md → 02-style.md} +11 -7
- package/skills/developing-cpp/references/comments/examples/{declaration-class.md → 01-declaration-class.md} +2 -1
- package/skills/developing-cpp/references/comments/examples/{declaration-constructor.md → 02-declaration-constructor.md} +2 -1
- package/skills/developing-cpp/references/comments/examples/{declaration-enum.md → 03-declaration-enum.md} +3 -3
- package/skills/developing-cpp/references/comments/examples/{declaration-file.md → 04-declaration-file.md} +4 -3
- package/skills/developing-cpp/references/comments/examples/{declaration-function.md → 05-declaration-function.md} +10 -29
- package/skills/developing-cpp/references/comments/examples/{declaration-member.md → 06-declaration-member.md} +1 -0
- package/skills/developing-cpp/references/comments/examples/07-declaration-predicate.md +15 -0
- package/skills/developing-cpp/references/comments/examples/{declaration-struct.md → 08-declaration-struct.md} +1 -0
- package/skills/developing-cpp/references/comments/examples/09-implementation-body.md +114 -0
- package/skills/developing-cpp/references/comments/examples/10-implementation-todo.md +17 -0
- package/skills/developing-cpp/references/comments/glossary/{comment-terms.md → 01-comment-terms.md} +8 -7
- package/skills/developing-cpp/references/design/{project-design.md → 01-project-design.md} +8 -7
- package/skills/developing-cpp/references/design/examples/{behavior-sentence.md → 01-behavior-sentence.md} +1 -0
- package/skills/developing-cpp/references/design/examples/{coordinate-table.md → 02-coordinate-table.md} +1 -0
- package/skills/developing-cpp/references/design/examples/{header-place.md → 03-header-place.md} +1 -0
- package/skills/developing-cpp/references/design/examples/{library-boundary.md → 04-library-boundary.md} +3 -2
- package/skills/developing-cpp/references/design/examples/{library-split.md → 05-library-split.md} +1 -0
- package/skills/developing-cpp/references/design/examples/{move-result.md → 06-move-result.md} +4 -10
- package/skills/developing-cpp/references/design/examples/{preview-read.md → 07-preview-read.md} +1 -0
- package/skills/developing-cpp/references/design/examples/08-screen-enter-exit.md +40 -0
- package/skills/developing-cpp/references/design/session-layer.md +91 -0
- package/skills/developing-cpp/references/exceptions/{throw-rules.md → 01-exception-rules.md} +10 -18
- package/skills/developing-cpp/references/exceptions/examples/{throw-boundary.md → 01-throw-boundary.md} +1 -0
- package/skills/developing-cpp/references/exceptions/examples/{throw-build-mode.md → 02-throw-build-mode.md} +3 -2
- package/skills/developing-cpp/references/exceptions/examples/{throw-catch.md → 03-throw-catch.md} +1 -0
- package/skills/developing-cpp/references/exceptions/examples/{throw-destructor.md → 04-throw-destructor.md} +1 -0
- package/skills/developing-cpp/references/exceptions/examples/{throw-format.md → 05-throw-format.md} +1 -0
- package/skills/developing-cpp/references/exceptions/examples/{throw-message.md → 06-throw-message.md} +2 -1
- package/skills/developing-cpp/references/exceptions/examples/{throw-when.md → 07-throw-when.md} +1 -0
- package/skills/developing-cpp/references/index.md +134 -0
- package/skills/developing-cpp/references/language/glossary/{language-terms.md → 01-language-terms.md} +3 -2
- package/skills/developing-cpp/references/language/language-basics/01-objects.md +1 -0
- package/skills/developing-cpp/references/language/language-basics/02-initialization.md +15 -7
- package/skills/developing-cpp/references/language/language-basics/03-deduction.md +1 -0
- package/skills/developing-cpp/references/language/language-basics/04-const.md +1 -0
- package/skills/developing-cpp/references/language/language-basics/05-expressions.md +7 -3
- package/skills/developing-cpp/references/language/language-basics/06-functions.md +6 -3
- package/skills/developing-cpp/references/language/language-basics/07-classes.md +1 -0
- package/skills/developing-cpp/references/language/language-basics/08-raii.md +1 -0
- package/skills/developing-cpp/references/language/language-basics/09-templates.md +1 -0
- package/skills/developing-cpp/references/language/language-basics/{10-checklist.md → 10-language-checklist.md} +2 -0
- package/skills/developing-cpp/references/language/performance/01-measure.md +1 -0
- package/skills/developing-cpp/references/language/performance/02-complexity.md +1 -0
- package/skills/developing-cpp/references/language/performance/03-memory.md +1 -0
- package/skills/developing-cpp/references/language/performance/04-undefined-behavior.md +1 -0
- package/skills/developing-cpp/references/language/performance/05-pitfalls.md +1 -0
- package/skills/developing-cpp/references/language/performance/06-false-optimizations.md +1 -0
- package/skills/developing-cpp/references/language/performance/07-checklist.md +1 -0
- package/skills/developing-cpp/references/language/standard-library/01-containers.md +5 -3
- package/skills/developing-cpp/references/language/standard-library/02-access.md +1 -0
- package/skills/developing-cpp/references/language/standard-library/03-iteration.md +1 -0
- package/skills/developing-cpp/references/language/standard-library/04-algorithms.md +1 -0
- package/skills/developing-cpp/references/language/standard-library/05-string.md +1 -0
- package/skills/developing-cpp/references/language/standard-library/06-format.md +5 -2
- package/skills/developing-cpp/references/language/standard-library/07-time.md +1 -0
- package/skills/developing-cpp/references/language/standard-library/08-random.md +2 -0
- package/skills/developing-cpp/references/language/standard-library/09-files.md +1 -0
- package/skills/developing-cpp/references/language/standard-library/{10-checklist.md → 10-library-checklist.md} +2 -1
- package/skills/developing-cpp/references/language/value-types/01-width.md +1 -0
- package/skills/developing-cpp/references/language/value-types/02-signed.md +1 -0
- package/skills/developing-cpp/references/language/value-types/03-integer-roles.md +1 -0
- package/skills/developing-cpp/references/language/value-types/04-enum.md +13 -1
- package/skills/developing-cpp/references/language/value-types/05-strong-type.md +1 -0
- package/skills/developing-cpp/references/language/value-types/06-const-method.md +1 -0
- package/skills/developing-cpp/references/language/value-types/07-nodiscard.md +1 -0
- package/skills/developing-cpp/references/language/value-types/08-comparison.md +1 -0
- package/skills/developing-cpp/references/language/value-types/09-subscript.md +2 -1
- package/skills/developing-cpp/references/language/value-types/10-float-bool.md +1 -0
- package/skills/developing-cpp/references/language/value-types/11-checklist.md +2 -0
- package/skills/developing-cpp/references/layout/01-source-layout.md +3 -2
- package/skills/developing-cpp/references/layout/02-file-template.md +4 -3
- package/skills/developing-cpp/references/layout/03-declaration-order.md +15 -4
- package/skills/developing-cpp/references/naming/{identifier-names.md → 01-identifier-names.md} +31 -9
- package/skills/developing-cpp/references/naming/examples/{naming-accessor.md → 01-naming-accessor.md} +1 -0
- package/skills/developing-cpp/references/naming/examples/02-naming-basic.md +4 -0
- package/skills/developing-cpp/references/naming/examples/{naming-current-prefix.md → 03-naming-current-prefix.md} +1 -0
- package/skills/developing-cpp/references/naming/examples/{naming-local.md → 04-naming-local.md} +2 -1
- package/skills/developing-cpp/references/naming/examples/{naming-lookup.md → 05-naming-lookup.md} +1 -0
- package/skills/developing-cpp/references/naming/examples/{naming-lower-layer.md → 06-naming-lower-layer.md} +2 -2
- package/skills/developing-cpp/references/naming/examples/{naming-multiple-return.md → 07-naming-multiple-return.md} +1 -0
- package/skills/developing-cpp/references/naming/examples/{naming-player-value.md → 08-naming-player-value.md} +1 -0
- package/skills/developing-cpp/references/naming/examples/{naming-predicate.md → 09-naming-predicate.md} +1 -0
- package/skills/developing-cpp/references/naming/examples/{naming-rename.md → 10-naming-rename.md} +1 -0
- package/skills/developing-cpp/references/naming/examples/{naming-responsibility.md → 11-naming-responsibility.md} +1 -0
- package/skills/developing-cpp/references/naming/examples/{naming-role.md → 12-naming-role.md} +1 -0
- package/skills/developing-cpp/references/naming/examples/{naming-state-change.md → 13-naming-state-change.md} +4 -4
- package/skills/developing-cpp/references/naming/glossary/01-naming-terms.md +28 -0
- package/skills/developing-cpp/references/naming/glossary/{position.md → 02-position.md} +2 -1
- package/skills/developing-cpp/references/naming/glossary/03-selection.md +23 -0
- package/skills/developing-cpp/references/naming/glossary/{square.md → 04-square.md} +3 -2
- package/skills/developing-cpp/references/naming/glossary/05-scoring.md +27 -0
- package/skills/developing-cpp/references/naming/glossary/06-difficulty.md +26 -0
- package/skills/developing-cpp/references/naming/glossary/07-stream.md +21 -0
- package/skills/developing-cpp/references/style/{google-cpp-style.md → 01-google-cpp-style.md} +16 -9
- package/skills/developing-cpp/scripts/checking-comments.mjs +107 -8
- package/skills/developing-cpp/steps/01-behavior.md +5 -5
- package/skills/developing-cpp/steps/02-boundary.md +6 -6
- package/skills/developing-cpp/steps/03-declaration.md +8 -8
- package/skills/developing-cpp/steps/04-implementation.md +17 -17
- package/skills/engineering/SKILL.md +14 -14
- package/skills/engineering/references/cmake/linking/01-libraries.md +7 -4
- package/skills/engineering/references/cmake/linking/02-rpath.md +1 -0
- package/skills/engineering/references/cmake/linking/03-undefined-reference.md +2 -1
- package/skills/engineering/references/cmake/linking/04-inspect.md +1 -1
- package/skills/engineering/references/cmake/modules/{functions.md → 01-functions.md} +3 -2
- package/skills/engineering/references/cmake/standards/{cxx-standard.md → 01-cxx-standard.md} +3 -2
- package/skills/engineering/references/cmake/standards/examples/{standard.md → 01-standard.md} +2 -1
- package/skills/engineering/references/cmake/standards/{README.md → index.md} +16 -15
- package/skills/engineering/references/cmake/standards/versions.md +44 -0
- package/skills/engineering/references/cmake/targets/{rules.md → 01-target-rules.md} +37 -5
- package/skills/engineering/references/cmake/targets/examples/{rpath.md → 01-rpath.md} +1 -0
- package/skills/engineering/references/cmake/testing/{ctest.md → 01-ctest.md} +3 -2
- package/skills/engineering/references/formatting/01-encoding.md +2 -1
- package/skills/engineering/references/formatting/02-clang-format.md +4 -2
- package/skills/engineering/references/formatting/03-clang-tidy.md +3 -2
- package/skills/engineering/references/formatting/04-clangd.md +2 -0
- package/skills/engineering/references/formatting/examples/{clang-format.md → 01-clang-format.md} +2 -1
- package/skills/engineering/references/formatting/examples/{clang-tidy.md → 02-clang-tidy.md} +1 -0
- package/skills/engineering/references/formatting/examples/{clangd.md → 03-clangd.md} +1 -0
- package/skills/engineering/references/index.md +32 -0
- package/skills/engineering/steps/01-targets.md +3 -3
- package/skills/engineering/steps/02-modules.md +3 -3
- package/skills/engineering/steps/03-check.md +1 -1
- package/skills/shared/budget.md +20 -0
- package/skills/{developing-cpp/references/editing/01-edit-operations.md → shared/operations.md} +7 -3
- package/skills/{developing-cpp/references/editing/02-rule-priority.md → shared/rule-priority.md} +8 -1
- package/skills/building-cpp/project/vscode/01-extensions.md +0 -28
- package/skills/developing-cpp/references/comments/examples/declaration-predicate.md +0 -14
- package/skills/developing-cpp/references/comments/examples/implementation-body.md +0 -81
- package/skills/developing-cpp/references/comments/examples/implementation-todo.md +0 -16
- package/skills/developing-cpp/references/naming/examples/naming-basic.md +0 -3
- package/skills/developing-cpp/references/naming/glossary/naming-terms.md +0 -23
- package/skills/engineering/references/cmake/standards/c++11/README.md +0 -50
- package/skills/engineering/references/cmake/standards/c++14/README.md +0 -48
- package/skills/engineering/references/cmake/standards/c++17/README.md +0 -50
- package/skills/engineering/references/cmake/standards/c++20/README.md +0 -50
- package/skills/engineering/references/cmake/standards/c++23/README.md +0 -50
- package/skills/engineering/references/cmake/targets/examples/glob.md +0 -22
- package/skills/engineering/references/cmake/targets/examples/target.md +0 -156
- /package/skills/engineering/{references/formatting/scripts → scripts}/checking-encoding.mjs +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// 只读注释审计:按 references/comments/comment-rules.md 的硬规则检查 C/C++ 源文件。
|
|
2
|
+
// 只读注释审计:按 references/comments/01-comment-rules.md 的硬规则检查 C/C++ 源文件。
|
|
3
3
|
//
|
|
4
4
|
// 检查项:Doxygen 文件头、注释行宽度、列表缩进、标签、标签间空行、注释与声明的贴合、
|
|
5
|
-
// 类型注释存在性、成员功能清单、设计论证(方案对比)、否定式边界、领域尺寸、谓词首句、@param
|
|
5
|
+
// 类型注释存在性、成员功能清单、设计论证(方案对比)、否定式边界、领域尺寸、谓词首句、@param 完整性、摘要裸参数名、枚举成员注释一致性、枚举行尾句式、数据成员主注释位置、定义处重复声明注释、只在 .cpp 出现的函数契约。
|
|
6
6
|
// 不重写任何文件。
|
|
7
7
|
//
|
|
8
8
|
// 用法:
|
|
@@ -20,6 +20,7 @@ const SOURCE_EXT = new Set([
|
|
|
20
20
|
'.cpp', '.cc', '.cxx', '.c++', '.c', '.m', '.mm',
|
|
21
21
|
])
|
|
22
22
|
const HEADER_EXT = new Set(['.h', '.hh', '.hpp', '.hxx', '.h++', '.inl', '.ipp', '.tpp'])
|
|
23
|
+
const CPP_EXT = new Set(['.cpp', '.cc', '.cxx', '.c++', '.c'])
|
|
23
24
|
const SKIP_DIR = new Set([
|
|
24
25
|
'.git', '.hg', '.svn', 'build', 'build-release', 'out', 'node_modules', '_book', '.quarto', '.cache',
|
|
25
26
|
'.tmp', 'temp', 'third_party', 'third-party', 'external', 'vendor', 'deps', 'cmake-build-debug',
|
|
@@ -42,8 +43,11 @@ const NEGATED_BOUNDARY = /只保存|不拥有|不含/
|
|
|
42
43
|
const NEGATIVE_SCOPE = /不(?:检查|校验|验证|负责|判断)/
|
|
43
44
|
const DOMAIN_SIZE = /\d+\s*[×xX]\s*\d+|九格|九个格子/
|
|
44
45
|
const PREDICATE_DECL = /^(?:\[\[nodiscard\]\]\s*)?(?:static\s+)?bool\s+(?:Is|Has|Can|Completes|Would)[A-Za-z0-9_]*\s*\(|operator==/
|
|
46
|
+
const PREDICATE_BANNED_PREFIX = /^(?:检查|判断|校验|验证)/
|
|
45
47
|
const isPredicateFirstOk = (declaration, firstDocLine) =>
|
|
46
|
-
|
|
48
|
+
declaration.includes('operator==')
|
|
49
|
+
? firstDocLine.startsWith('相等运算符')
|
|
50
|
+
: firstDocLine.includes('是否') && !PREDICATE_BANNED_PREFIX.test(firstDocLine)
|
|
47
51
|
const DECL_KEYWORDS = /^(class|struct|union|enum|namespace|using|typedef|template|#|if|else|for|while|switch|return|case|default)\b/
|
|
48
52
|
|
|
49
53
|
function usage(message) {
|
|
@@ -242,6 +246,86 @@ export function functionParams(declaration) {
|
|
|
242
246
|
return splitParams(decl.slice(open + 1, close)).map(paramName).filter(Boolean)
|
|
243
247
|
}
|
|
244
248
|
|
|
249
|
+
/** 收集头文件里声明的函数名,供 .cpp 定义处配对;声明可以跨行。 */
|
|
250
|
+
function declarationNames(text) {
|
|
251
|
+
const names = new Set()
|
|
252
|
+
let buffer = ''
|
|
253
|
+
for (const line of text.split(/\r?\n/)) {
|
|
254
|
+
const trimmed = line.trim()
|
|
255
|
+
if (trimmed === '' || trimmed.startsWith('//') || trimmed.startsWith('*') || trimmed.startsWith('/*') || trimmed.startsWith('#')) continue
|
|
256
|
+
buffer = buffer === '' ? trimmed : `${buffer} ${trimmed}`
|
|
257
|
+
if (!buffer.includes(';')) continue
|
|
258
|
+
const declaration = buffer
|
|
259
|
+
buffer = ''
|
|
260
|
+
if (/^(if|for|while|switch|catch|else|return|case|default|do)\b/.test(declaration)) continue
|
|
261
|
+
const match = declaration.match(/^(.*?)\b([A-Za-z_]\w*)\s*\(([^;{}]*)\)\s*(?:const\s*)?(?:noexcept\s*)?(?:override\s*)?(?:final\s*)?(?:=\s*(?:0|default|delete)\s*)?;$/)
|
|
262
|
+
if (match) names.add(match[2])
|
|
263
|
+
}
|
|
264
|
+
return names
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/** 取定义行上的函数名、返回类型与参数名;不是单行定义时返回 undefined。 */
|
|
268
|
+
function definitionAt(lines, index) {
|
|
269
|
+
const line = lines[index]
|
|
270
|
+
if (/^\s*(if|for|while|switch|catch|else|return|case|default|do)\b/.test(line)) return undefined
|
|
271
|
+
if (/^\s*[A-Z][A-Z0-9_]*\s*\(/.test(line)) return undefined
|
|
272
|
+
const match = line.match(/^(\s*)(.*?)\b([A-Za-z_]\w*)\s*\(([^)]*)\)\s*(?:const\s*)?(?:noexcept\s*)?(?:->\s*[^{]+)?\{\s*.*$/)
|
|
273
|
+
if (!match) return undefined
|
|
274
|
+
const prefix = match[2].trim()
|
|
275
|
+
if (/^(if|for|while|switch|catch|else|return|case|default|do)$/.test(match[3])) return undefined
|
|
276
|
+
if (prefix.endsWith('::~')) return undefined
|
|
277
|
+
const returnType = prefix.replace(/[A-Za-z_]\w*::$/, '').trim()
|
|
278
|
+
return { name: match[3], returnType, params: splitParams(match[4]).map(paramName).filter(Boolean) }
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/** 取定义上一行紧贴的 /// 文档块。 */
|
|
282
|
+
function docAbove(lines, index) {
|
|
283
|
+
let cursor = index - 1
|
|
284
|
+
if (cursor < 0 || !lines[cursor].trim().startsWith('///')) return undefined
|
|
285
|
+
const contents = []
|
|
286
|
+
let start = cursor
|
|
287
|
+
while (cursor >= 0 && lines[cursor].trim().startsWith('///')) {
|
|
288
|
+
contents.unshift(lines[cursor].trim().replace(/^\/\/\/\s?/, ''))
|
|
289
|
+
start = cursor
|
|
290
|
+
cursor -= 1
|
|
291
|
+
}
|
|
292
|
+
return { start, contents }
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/** 检查 .cpp 定义处的注释落点:头文件已声明的定义不写 ///,只在 .cpp 出现的函数写完整契约。 */
|
|
296
|
+
export function checkDefinitionDocs(text, headerNames = new Set()) {
|
|
297
|
+
const issues = []
|
|
298
|
+
const lines = text.split(/\r?\n/)
|
|
299
|
+
for (let index = 0; index < lines.length; index += 1) {
|
|
300
|
+
const definition = definitionAt(lines, index)
|
|
301
|
+
if (!definition || definition.name === 'main' || definition.name.startsWith('operator')) continue
|
|
302
|
+
const doc = docAbove(lines, index)
|
|
303
|
+
if (headerNames.has(definition.name)) {
|
|
304
|
+
if (doc) {
|
|
305
|
+
issues.push({ line: doc.start + 1, rule: 'doc-on-definition', message: '定义处重复了头文件声明注释:删掉这里的 ///,契约留在声明处' })
|
|
306
|
+
}
|
|
307
|
+
continue
|
|
308
|
+
}
|
|
309
|
+
const needsContract = definition.params.length > 0 || (definition.returnType !== '' && definition.returnType !== 'void')
|
|
310
|
+
if (!needsContract) continue
|
|
311
|
+
if (!doc) {
|
|
312
|
+
issues.push({ line: index + 1, rule: 'cpp-contract-missing', message: '只在 .cpp 出现的函数缺少完整契约:在定义上一行补 @param/@return' })
|
|
313
|
+
continue
|
|
314
|
+
}
|
|
315
|
+
const block = doc.contents.join('\n')
|
|
316
|
+
const documented = [...block.matchAll(/@param(?:\[[^\]]*\])?\s+(\w+)/g)].map((match) => match[1])
|
|
317
|
+
for (const name of definition.params) {
|
|
318
|
+
if (!documented.includes(name)) {
|
|
319
|
+
issues.push({ line: doc.start + 1, rule: 'cpp-contract-missing', message: `只在 .cpp 出现的函数缺少 @param ${name}:补完整契约` })
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
if (definition.returnType !== '' && definition.returnType !== 'void' && !/@return\b/.test(block)) {
|
|
323
|
+
issues.push({ line: doc.start + 1, rule: 'cpp-contract-missing', message: '只在 .cpp 出现的函数缺少 @return:补完整契约' })
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
return issues
|
|
327
|
+
}
|
|
328
|
+
|
|
245
329
|
/** 取函数注释第一段:遇到空行或 Doxygen 标签就结束。 */
|
|
246
330
|
function summaryParagraph(contents) {
|
|
247
331
|
const paragraph = []
|
|
@@ -365,7 +449,7 @@ export function checkText(text, options = {}) {
|
|
|
365
449
|
for (const name of namesToCheck) {
|
|
366
450
|
if (name !== own) add(headerLine, 'header-cross-file', `文件头提到了别的源文件 ${name}:只介绍本文件,删掉跨文件句子`)
|
|
367
451
|
}
|
|
368
|
-
if (/\
|
|
452
|
+
if (/\b(?:app|src|include|tests)\//.test(text)) add(headerLine, 'header-cross-file', '文件头指向了另一个目录:只介绍本文件')
|
|
369
453
|
}
|
|
370
454
|
}
|
|
371
455
|
|
|
@@ -379,7 +463,7 @@ export function checkText(text, options = {}) {
|
|
|
379
463
|
}
|
|
380
464
|
for (const tag of FORBIDDEN_TAGS) {
|
|
381
465
|
if (options.allowTags?.has(tag.slice(1))) continue
|
|
382
|
-
if (trimmed.includes(tag)) add(index + 1, 'forbidden-tag', `禁止使用 ${tag},按 references/comments/comment-rules.md 的标签表改写`)
|
|
466
|
+
if (trimmed.includes(tag)) add(index + 1, 'forbidden-tag', `禁止使用 ${tag},按 references/comments/01-comment-rules.md 的标签表改写`)
|
|
383
467
|
}
|
|
384
468
|
}
|
|
385
469
|
}
|
|
@@ -393,7 +477,7 @@ export function checkText(text, options = {}) {
|
|
|
393
477
|
if (displayWidth(rendered) > width) add(doc.start + 1, 'comment-width', `注释行 ${displayWidth(rendered)} 列,超过 ${width} 列`)
|
|
394
478
|
for (const tag of FORBIDDEN_TAGS) {
|
|
395
479
|
if (options.allowTags?.has(tag.slice(1))) continue
|
|
396
|
-
if (content.includes(tag)) add(doc.start + 1, 'forbidden-tag', `禁止使用 ${tag},按 references/comments/comment-rules.md 的标签表改写`)
|
|
480
|
+
if (content.includes(tag)) add(doc.start + 1, 'forbidden-tag', `禁止使用 ${tag},按 references/comments/01-comment-rules.md 的标签表改写`)
|
|
397
481
|
}
|
|
398
482
|
}
|
|
399
483
|
for (let raw = doc.start; raw <= doc.end; raw += 1) {
|
|
@@ -460,7 +544,7 @@ export function checkText(text, options = {}) {
|
|
|
460
544
|
}
|
|
461
545
|
const firstDocLine = lines[start].trim().replace(/^\/\/\/\s*/, '')
|
|
462
546
|
if (!isType && PREDICATE_DECL.test(declaration) && !isPredicateFirstOk(declaration, firstDocLine)) {
|
|
463
|
-
add(start + 1, 'predicate-first', '
|
|
547
|
+
add(start + 1, 'predicate-first', '布尔查询的第一句应写「…是否…」,句首不用「检查/判断/校验/验证」;operator== 写「相等运算符」')
|
|
464
548
|
}
|
|
465
549
|
const params = functionParams(declaration)
|
|
466
550
|
if (!params) continue
|
|
@@ -509,7 +593,7 @@ export function checkText(text, options = {}) {
|
|
|
509
593
|
if (isType && DOMAIN_SIZE.test(block)) add(doc.start + 1, 'domain-size', '类型注释在写领域尺寸:格子数由 squares_ 之类成员声明表达,删掉这句')
|
|
510
594
|
const firstDocLine = doc.contents[0] ?? ''
|
|
511
595
|
if (!isType && PREDICATE_DECL.test(declaration) && !isPredicateFirstOk(declaration, firstDocLine)) {
|
|
512
|
-
add(doc.start + 1, 'predicate-first', '
|
|
596
|
+
add(doc.start + 1, 'predicate-first', '布尔查询的第一句应写「…是否…」,句首不用「检查/判断/校验/验证」;operator== 写「相等运算符」')
|
|
513
597
|
}
|
|
514
598
|
const params = functionParams(declaration)
|
|
515
599
|
if (!params) continue
|
|
@@ -676,6 +760,7 @@ function main(argv) {
|
|
|
676
760
|
return usage(`读取 ${root} 失败:${error.message}`)
|
|
677
761
|
}
|
|
678
762
|
const results = []
|
|
763
|
+
const texts = new Map()
|
|
679
764
|
for (const file of files) {
|
|
680
765
|
let text
|
|
681
766
|
try {
|
|
@@ -684,6 +769,7 @@ function main(argv) {
|
|
|
684
769
|
process.stderr.write(`错误:读取 ${file} 失败:${error.message}\n`)
|
|
685
770
|
return EXIT.usage
|
|
686
771
|
}
|
|
772
|
+
texts.set(file, text)
|
|
687
773
|
const width = options.widthExplicit
|
|
688
774
|
? options.width
|
|
689
775
|
: (readColumnLimitNear(file, root) ?? options.width)
|
|
@@ -691,6 +777,19 @@ function main(argv) {
|
|
|
691
777
|
results.push({ file: path.relative(root, file) || file, ...issue })
|
|
692
778
|
}
|
|
693
779
|
}
|
|
780
|
+
const headerNames = new Set()
|
|
781
|
+
for (const file of files) {
|
|
782
|
+
if (HEADER_EXT.has(path.extname(file).toLowerCase())) {
|
|
783
|
+
for (const name of declarationNames(texts.get(file))) headerNames.add(name)
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
for (const file of files) {
|
|
787
|
+
if (!CPP_EXT.has(path.extname(file).toLowerCase())) continue
|
|
788
|
+
for (const issue of checkDefinitionDocs(texts.get(file), headerNames)) {
|
|
789
|
+
results.push({ file: path.relative(root, file) || file, ...issue })
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
results.sort((left, right) => left.file.localeCompare(right.file) || left.line - right.line)
|
|
694
793
|
if (options.json) {
|
|
695
794
|
process.stdout.write(`${JSON.stringify({ root, files: files.length, issues: results }, null, 2)}\n`)
|
|
696
795
|
} else if (results.length > 0) {
|
|
@@ -15,14 +15,14 @@
|
|
|
15
15
|
- 可观察的是终端输出、文件内容、退出码和库函数的返回值;内部状态不算可观察行为。
|
|
16
16
|
- 一次只定一个可验收的切片;切片太大就拆成两句行为,各走一遍四步。
|
|
17
17
|
- 失败方式与成功路径同写:非法参数、空输入、越界、文件不存在时,是返回错误值、打印提示,还是抛异常。
|
|
18
|
-
-
|
|
19
|
-
- 操作与范围按
|
|
18
|
+
- 写到已有的 `std::ostream` 用 `<<`;没有流对象时,默认用 `std::print` 与 `std::println`,它们只在 C++23 且标准库支持时可用;见 `references/language/standard-library/06-format.md`。
|
|
19
|
+
- 操作与范围按 `../../shared/operations.md` 判:本步是写作的入口;改写只在行为被打破时回到这里。
|
|
20
20
|
|
|
21
21
|
## 情况
|
|
22
22
|
|
|
23
23
|
**新功能**:先写最小可观察切片,例如「输入名字,输出一句问候」。交互、存档、排行榜不一次写进第 1 步。
|
|
24
24
|
|
|
25
|
-
**领域规则**:先把动词和名词写成领域值——任务、状态、动作、结果。取值封闭时用 `enum class`;规则有歧义时列出至少两个解释并问用户,不静默选一个。领域值怎么选见 `references/design/project-design.md`。
|
|
25
|
+
**领域规则**:先把动词和名词写成领域值——任务、状态、动作、结果。取值封闭时用 `enum class`;规则有歧义时列出至少两个解释并问用户,不静默选一个。领域值怎么选见 `references/design/01-project-design.md`。
|
|
26
26
|
|
|
27
27
|
**修缺陷**:行为句写成「现在观察到 X,期望观察到 Y」,并保留复现输入。修完只验证 X → Y。
|
|
28
28
|
|
|
@@ -32,5 +32,5 @@
|
|
|
32
32
|
|
|
33
33
|
## 正反例指针
|
|
34
34
|
|
|
35
|
-
- 边界怎么切、库和程序怎么分:`references/design/examples/library-boundary.md`。
|
|
36
|
-
- 行为句写得太大或混入实现:`references/design/examples/behavior-sentence.md`。
|
|
35
|
+
- 边界怎么切、库和程序怎么分:`references/design/examples/04-library-boundary.md`。
|
|
36
|
+
- 行为句写得太大或混入实现:`references/design/examples/01-behavior-sentence.md`。
|
|
@@ -11,15 +11,15 @@ app 职责:参数、输入输出、装配 依赖:<component>
|
|
|
11
11
|
|
|
12
12
|
## 通用情况
|
|
13
13
|
|
|
14
|
-
- 库接收值、返回值,在无法完成任务时抛异常;终端、GUI、网络脚本与全局单例留在程序层。返回值与异常的取舍见 `references/exceptions/
|
|
14
|
+
- 库接收值、返回值,在无法完成任务时抛异常;终端、GUI、网络脚本与全局单例留在程序层。返回值与异常的取舍见 `references/exceptions/01-exception-rules.md`。
|
|
15
15
|
- 程序链接库,负责读参数、读标准输入、打印结果,并把退出码翻译成进程退出码。
|
|
16
16
|
- 依赖方向从程序指向库;组件之间只经由公共头互相依赖。
|
|
17
|
-
- 公共头放在组件的 `include/` 下,包含时写裸文件名;搜索路径由 target 的 `target_include_directories(... PUBLIC .../include)` 提供,写法见 `engineering` 的 `cmake/targets/rules.md`。
|
|
17
|
+
- 公共头放在组件的 `include/` 下,包含时写裸文件名;搜索路径由 target 的 `target_include_directories(... PUBLIC .../include)` 提供,写法见 `engineering` 的 `cmake/targets/01-target-rules.md`。
|
|
18
18
|
- 测试放 `tests/`,链接被测库,从公共头进入;文件命名 `<被测>_test.cpp`,一个文件对应一个行为组,测试名描述行为,不复制实现、不依赖执行顺序、不读写固定绝对路径。
|
|
19
19
|
- 只有一个可执行文件、没有复用需求时不分库;出现第二个真实调用方,或测试需要直接调用时再拆。
|
|
20
20
|
- 抽共享抽象前先确认第二个真实使用方和相同语义;抽象理由写进项目技能或设计注释。
|
|
21
21
|
- 本步只决定边界:`CMakeLists.txt` 与 target 图由 `engineering` 的 `steps/01-targets.md` 写,构建与工具配置由 `building-cpp` 定。
|
|
22
|
-
- 一个查询该成为成员还是同命名空间的函数,按 `references/design/project-design.md` 的「谁回答这个问题」判:掌握数据的一方回答。
|
|
22
|
+
- 一个查询该成为成员还是同命名空间的函数,按 `references/design/01-project-design.md` 的「谁回答这个问题」判:掌握数据的一方回答。
|
|
23
23
|
|
|
24
24
|
## 情况
|
|
25
25
|
|
|
@@ -29,11 +29,11 @@ app 职责:参数、输入输出、装配 依赖:<component>
|
|
|
29
29
|
|
|
30
30
|
**库 + 程序**:库放在 `<component>/`,程序放在 `app/` 或根 `src/main.cpp`;程序只包含库的公共头,实现细节留在 `.cpp` 或私有头。
|
|
31
31
|
|
|
32
|
-
**静态库 / 动态库**:接口相同,差别在链接方式和运行时库路径;都遵守「库不依赖终端」。选哪种由 `engineering` 的定 target 步骤决定,运行时路径写法见其 `cmake/targets/rules.md`。
|
|
32
|
+
**静态库 / 动态库**:接口相同,差别在链接方式和运行时库路径;都遵守「库不依赖终端」。选哪种由 `engineering` 的定 target 步骤决定,运行时路径写法见其 `cmake/targets/01-target-rules.md`。
|
|
33
33
|
|
|
34
34
|
**测试**:测试通过公共头调用库;需要测私有逻辑时,先判断它是否应该成为公共行为。
|
|
35
35
|
|
|
36
36
|
## 正反例指针
|
|
37
37
|
|
|
38
|
-
- 终端输出被塞进库、程序反向依赖:`references/design/examples/library-boundary.md`。
|
|
39
|
-
- 公共头放在 `src/`、测试被迫包含私有头:`references/design/examples/header-place.md`。
|
|
38
|
+
- 终端输出被塞进库、程序反向依赖:`references/design/examples/04-library-boundary.md`。
|
|
39
|
+
- 公共头放在 `src/`、测试被迫包含私有头:`references/design/examples/03-header-place.md`。
|
|
@@ -8,16 +8,16 @@
|
|
|
8
8
|
|
|
9
9
|
- 语言标准由项目声明决定,新工程默认 C++23(C++11–C++23);`environment.json` 的 `standard` 是唯一来源。
|
|
10
10
|
- 文件槽位、包含守卫与扩展名以 `references/layout/02-file-template.md` 为准;本步只决定声明写什么。
|
|
11
|
-
- 命名以 `references/naming/identifier-names.md` 为准:规则表、语义角色、谓词与查询命名都在那里;字符集、保留标识符与不向 `std` 添加声明见同文件的「字符集与保留标识符」。
|
|
11
|
+
- 命名以 `references/naming/01-identifier-names.md` 为准:规则表、语义角色、谓词与查询命名都在那里;字符集、保留标识符与不向 `std` 添加声明见同文件的「字符集与保留标识符」。
|
|
12
12
|
- 声明顺序以 `references/layout/03-declaration-order.md` 为准:类型 → 静态常量 → 工厂 → 构造/赋值/析构 → 其他函数 → 数据成员。组内次序也按同一份的「其他函数的组内次序」:`operator==` 开头、`Get` 按数据成员顺序、先 `ClearSquare` 后 `Clear`;声明区空行按「空行」表,组间 1 行、数据成员间 0 行、`private:` 前 1 行、连续两空行是缺陷。数据成员按初始化依赖、逻辑分组和阅读顺序排列,不按字母序;先声明先初始化,初始化器只能安全使用已经完成初始化的成员。
|
|
13
13
|
- 公共头自包含:自己用到的类型、宏和标准库头都直接包含。验证方式:建一个只包含该头的空 `.cpp` 编译一次,不通过就补 include;五条自检见 `references/layout/02-file-template.md` 的「自检」。
|
|
14
|
-
- 单参数构造函数写 `explicit`;查询成员函数尾部写 `const`;返回结果对象的 API 加 `[[nodiscard]]`,标注位置与 `friend` 的例外见 `references/language/value-types/07-nodiscard.md
|
|
14
|
+
- 单参数构造函数写 `explicit`;查询成员函数尾部写 `const`;返回结果对象的 API 加 `[[nodiscard]]`,标注位置与 `friend` 的例外见 `references/language/value-types/07-nodiscard.md`;默认成员初始化写在声明处。初始化默认用花括号,详见 `references/language/language-basics/02-initialization.md`;该页说明 `std::vector<int>(n)` 这类容量构造为什么保留 `()`。特殊成员(含 `= default`)按声明顺序放在成员组最前,定义位置见 `references/layout/03-declaration-order.md`。
|
|
15
15
|
- 头文件只就地定义约 10 行以内的短函数;模板与 `constexpr` 例外,其余函数体在 `.cpp`。头文件里不写 `using namespace`、非 `inline` 普通全局变量、匿名命名空间或 `static` 定义。
|
|
16
|
-
-
|
|
17
|
-
- 一次操作有多种必须区分的正常结果时用 `enum class`
|
|
18
|
-
- 声明注释按 `references/comments/comment-rules.md`(内容)与 `references/comments/
|
|
16
|
+
- 失败是调用方的正常结果时,用结果类型或 `std::optional` 表达;输出参数只留给热循环里复用 `std::string` 或 `std::vector` 容量的例外,终端读入不使用。函数无法完成自己的任务、或构造函数无法建立不变量时才抛,异常类型的选择与消息见 `references/exceptions/01-exception-rules.md`。析构与 `swap` 标 `noexcept`,异常类型的拷贝/移动不抛;「拒绝」与「抛」并存时在公共头各写一行。
|
|
17
|
+
- 一次操作有多种必须区分的正常结果时用 `enum class` 返回(如落子:成功、玩家不对、终局、占用),不用 `bool` 把原因压掉;成功还要附带数据时再考虑 `std::expected` 或结果结构。纯查询谓词仍用 `bool`。枚举项逐个写值,状态与结果枚举把 0 留给正常态(空、进行中或成功),失败态按固定顺序随后;身份枚举按领域编号(如 X=1、O=2),不套用 0 = 正常态;封闭状态码的枚举默认写 `: std::uint8_t` 并逐个写值,普通枚举用默认底层类型;确需其他 ABI 宽度时写明理由;都不靠第一项默认为 0(见 `references/language/value-types/04-enum.md`);不要用 `bool` 开关参数承载两种以上行为(见 `references/language/value-types/10-float-bool.md`)。
|
|
18
|
+
- 声明注释按 `references/comments/01-comment-rules.md`(内容)与 `references/comments/02-style.md`(结构、版式、措辞)写:类型注释、特殊成员、函数注释、数据成员。本步只决定「写哪些事实」:结果、失败方式、检查项、参数与返回值契约;句式、标签、宽度和示例由后两份定,行宽跟 `.clang-format` 的 `ColumnLimit`(默认 80,中文按两列),枚举项与 `struct` 短字段的行尾注释用 `///<` 并与声明对齐。判不准用词时再开 `references/comments/glossary/01-comment-terms.md`,它只列词表,不重复句式。私有函数同样写声明契约,不能默认调用者知道前置条件;输出参数标 `[out]`,既读又写标 `[in,out]`。
|
|
19
19
|
- 自定义类型的 `std::formatter` 特化放在类型头文件;`parse` 的默认格式限制、`format` 的复用与非法值回退见 `references/language/standard-library/06-format.md` 的「自定义类型的格式化」。
|
|
20
|
-
-
|
|
20
|
+
- 写到已有的 `std::ostream` 用 `<<`;没有流对象时,默认用 `std::print` 与 `std::println`,它们只在 C++23 且标准库支持时可用;见 `references/language/standard-library/06-format.md`。
|
|
21
21
|
|
|
22
22
|
## 情况
|
|
23
23
|
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
|
|
30
30
|
**异常声明**:构造函数、`Get` 类查询、解析函数最容易抛;在声明注释里写「当……时抛出 `std::out_of_range`」这样的具体类型,不给每个参数错误新建类型。
|
|
31
31
|
|
|
32
|
-
**注释**:声明注释用 `///` 写中文散文,只写调用方需要知道的事实,实现细节留给 `.cpp`。文件头、标签、参数完整性与设计论证的规则见 `references/comments/comment-rules.md` 与 `references/comments/
|
|
32
|
+
**注释**:声明注释用 `///` 写中文散文,只写调用方需要知道的事实,实现细节留给 `.cpp`。文件头、标签、参数完整性与设计论证的规则见 `references/comments/01-comment-rules.md` 与 `references/comments/02-style.md`。类型注释先写一句名词短语;纯值容器到此为止,初始状态归默认构造函数,写入与清空条件归对应函数。只有类有不变量才加第二段,且不写别的类型负责什么,也不列「不检查…」这类能力边界。写完运行:
|
|
33
33
|
|
|
34
34
|
```bash
|
|
35
35
|
node "<skill-dir>/scripts/checking-comments.mjs" --root <项目根>
|
|
@@ -41,4 +41,4 @@ node "<skill-dir>/scripts/checking-comments.mjs" --root <项目根>
|
|
|
41
41
|
|
|
42
42
|
- 命名、访问器、语义角色:`references/naming/examples/`。
|
|
43
43
|
- 异常声明与返回值选择:`references/exceptions/examples/`。
|
|
44
|
-
- 声明注释写成了实现说明:`references/comments/examples/declaration-function.md`。
|
|
44
|
+
- 声明注释写成了实现说明:`references/comments/examples/05-declaration-function.md`。
|
|
@@ -8,20 +8,20 @@
|
|
|
8
8
|
|
|
9
9
|
- 函数保持短小,一个函数只做一件事。超过约 40 行时先找可以命名的中间步骤,不靠注释把长函数切成几段。
|
|
10
10
|
- 按「准备 → 操作 → 收尾」排列语句,用空行分组;组与组之间的空行表达阶段,同一组内的守卫与结果处理不插空行。
|
|
11
|
-
- `.cpp` 里的定义顺序跟配对头文件:先类型与常量,再自由函数,再成员函数;成员函数按类内声明顺序。头文件把构造函数、析构函数、拷贝/移动声明在成员组最前时,定义也放最前;如果头文件把它们声明在别的成员之后,仍按头文件顺序,不硬提。不为先编译重排,也不按调用频率重排。`.cpp` 里不需要外部引用的 `constexpr` 放具名命名空间,仅一个函数使用时才用函数内 `static constexpr
|
|
11
|
+
- `.cpp` 里的定义顺序跟配对头文件:先类型与常量,再自由函数,再成员函数;成员函数按类内声明顺序。头文件把构造函数、析构函数、拷贝/移动声明在成员组最前时,定义也放最前;如果头文件把它们声明在别的成员之后,仍按头文件顺序,不硬提。不为先编译重排,也不按调用频率重排。`.cpp` 里不需要外部引用的 `constexpr` 放具名命名空间,仅一个函数使用时才用函数内 `static constexpr`;函数与类型放唯一的匿名命名空间,公开函数定义放在其后;不另开具名子命名空间,也不用类的 `static` 成员来隐藏函数。见 `references/layout/03-declaration-order.md`「`.cpp` 的定义顺序」与 `references/style/01-google-cpp-style.md`。
|
|
12
12
|
- 同一文件里的函数按同一套分段约定:需要分阶段的非单表达式函数按空行分段、每段上方一句;读入、单值转换、一行输出这类一条直路的短函数不加分段注释;不能结构相近的函数一半分段、一半完全不留注释。阶段怎么分见 `references/layout/03-declaration-order.md`「函数体内的空行」。
|
|
13
|
-
- `.cpp` 的第一个 include 是自己的配对头,然后直接包含本文件用到的标准库头,不依赖公共头转发声明。包含顺序见 `references/style/google-cpp-style.md`,文件槽位见 `references/layout/02-file-template.md`。
|
|
14
|
-
- 函数体注释用 `//`,不用 `///`:体内 `///` 会接到该函数的 Doxygen 详细说明后面。重要函数按空行分阶段,每个阶段上方写一句 `//`,写这一支在检查什么,可以点明处理了哪些枚举值,不逐词翻译下一行的条件;`//` 里的枚举值不加反引号。单表达式函数(如 `IsEmpty`)不配注释;关键局部表(查表、分派表)上方写一句,说明表的角色与分组。只写删掉会让下一次修改得到错误结果、而代码本身看不出的内容;变更史留给提交说明。`.cpp`
|
|
15
|
-
- 什么时候在 `if` 上方加一句:多条独立拒绝(如 `Game::Place
|
|
16
|
-
-
|
|
17
|
-
- 失败是调用方正常结果时返回结果类型、`bool` 或 `std::optional`;函数无法完成自己的任务时抛异常,不拿异常做正常分支。Debug 与 Release 用同一套返回值与抛出条件,只有诊断详略不同。两种模式都要守的不变量用 `Check`(项目保留时),只在开发期做的自检用 `DebugCheck`;项目没有这两个宏时,`Check` 用 `std::terminate()` 兜底,`DebugCheck` 用 `assert`;`assert` 在 Release 不求值,不能代替 `Check`。`Check` 不是 `[[noreturn]]`,条件成立时正常返回;`DebugCheck` 的参数在 Release 不求值,不能放入有副作用的表达式。捕获时按 `const` 引用,只处理能处理的类型,其余继续抛。异常类型、消息格式与「不抛的边界」见 `references/exceptions/
|
|
18
|
-
- 参数校验、调用方状态检查与正常结果返回的次序见 `references/exceptions/
|
|
13
|
+
- `.cpp` 的第一个 include 是自己的配对头,然后直接包含本文件用到的标准库头,不依赖公共头转发声明。包含顺序见 `references/style/01-google-cpp-style.md`,文件槽位见 `references/layout/02-file-template.md`。
|
|
14
|
+
- 函数体注释用 `//`,不用 `///`:体内 `///` 会接到该函数的 Doxygen 详细说明后面。重要函数按空行分阶段,每个阶段上方写一句 `//`,写这一支在检查什么,可以点明处理了哪些枚举值,不逐词翻译下一行的条件;`//` 里的枚举值不加反引号。单表达式函数(如 `IsEmpty`)不配注释;关键局部表(查表、分派表)上方写一句,说明表的角色与分组。只写删掉会让下一次修改得到错误结果、而代码本身看不出的内容;变更史留给提交说明。`.cpp` 里只在 .cpp 出现的函数才写 `///`:有参数或返回值时写完整契约(`@param`、`@return`、`@pre`),与头文件声明同一套标签;头文件已声明的定义处不写 `///`;类方法定义不重复声明处已有的事实。
|
|
15
|
+
- 什么时候在 `if` 上方加一句:多条独立拒绝(如 `Game::Place`)不逐条注释,只有失败结果的优先级需要说明时在第一条 `if` 上方写一句总起;成功写入前一句;只有次序依赖的一对 `if` 在第一个上方说明;循环上方已有阶段说明时,循环里的 `if` 不再加;单表达式谓词不加。
|
|
16
|
+
- 枚举全覆盖不写 `default`,单条 `return` 不加花括号,`std::unreachable()` 紧跟 `switch` 右花括号;细节见 `references/language/language-basics/05-expressions.md`。
|
|
17
|
+
- 失败是调用方正常结果时返回结果类型、`bool` 或 `std::optional`;函数无法完成自己的任务时抛异常,不拿异常做正常分支。Debug 与 Release 用同一套返回值与抛出条件,只有诊断详略不同。两种模式都要守的不变量用 `Check`(项目保留时),只在开发期做的自检用 `DebugCheck`;项目没有这两个宏时,`Check` 用 `std::terminate()` 兜底,`DebugCheck` 用 `assert`;`assert` 在 Release 不求值,不能代替 `Check`。`Check` 不是 `[[noreturn]]`,条件成立时正常返回;`DebugCheck` 的参数在 Release 不求值,不能放入有副作用的表达式。捕获时按 `const` 引用,只处理能处理的类型,其余继续抛。异常类型、消息格式与「不抛的边界」见 `references/exceptions/01-exception-rules.md`。
|
|
18
|
+
- 参数校验、调用方状态检查与正常结果返回的次序见 `references/exceptions/01-exception-rules.md` 的「检查次序」:先整局状态,再进行中的玩家,最后交给下层检查坐标与占用,下层检查不重复。改完 `throw` 再走同文件的「检查清单」:异常类型、消息标签、跨行消息先存变量、不吞异常。
|
|
19
19
|
- 声明 `noexcept` 前核对函数体:出现 `at()` 或其他可能抛出的调用就去掉。越界用 `at()` 抛 `std::out_of_range`,这个函数就不能标 `noexcept`。普通查询和返回结果枚举的函数,不因为当前函数体不抛就补 `noexcept`;它留给移动、交换、析构,以及已经标上的纯谓词。
|
|
20
|
-
-
|
|
20
|
+
- 写到已有的 `std::ostream` 用 `<<`;没有流对象时,默认用 `std::print` 与 `std::println`,它们只在 C++23 且标准库支持时可用;见 `references/language/standard-library/06-format.md`。
|
|
21
21
|
- 转换用具名转换 `static_cast` / `std::bit_cast`,不用 C 风格强制转换。
|
|
22
22
|
- 所有权用 `std::unique_ptr`;禁止裸 `new` / `delete`,没有共享所有权的理由时不用 `std::shared_ptr`。
|
|
23
23
|
- 只改注释时,不改可观察行为;只改实现时,不改公共声明。两者同时需要时,先改声明,再改实现。
|
|
24
|
-
- 清空成员数组:元素类型只提供赋值入口时(如 `Square::SetValue`),容器的 `ClearSquare` 调用 `SetValue(kEmpty)`,`Clear` 再逐格调用 `ClearSquare`;不要把清空操作放回值对象。不要直接写 `squares_ = {}`,也不要从外部把枚举赋成空值。撤销只回退受影响的那一处,不清空整个容器再重放全部历史,见 `references/design/project-design.md` 的「撤销与回退」。
|
|
24
|
+
- 清空成员数组:元素类型只提供赋值入口时(如 `Square::SetValue`),容器的 `ClearSquare` 调用 `SetValue(kEmpty)`,`Clear` 再逐格调用 `ClearSquare`;不要把清空操作放回值对象。不要直接写 `squares_ = {}`,也不要从外部把枚举赋成空值。撤销只回退受影响的那一处,不清空整个容器再重放全部历史,见 `references/design/01-project-design.md` 的「撤销与回退」。
|
|
25
25
|
- 默认构造只做「建立初值」时用成员初值(如 `squares_{}`),不在构造函数里再调一遍 `Clear()`;`Clear()` 只负责把已经写入的值清空为 `kEmpty`。
|
|
26
26
|
|
|
27
27
|
## 情况
|
|
@@ -36,15 +36,15 @@
|
|
|
36
36
|
|
|
37
37
|
## 交回构建
|
|
38
38
|
|
|
39
|
-
实现改完,先对照配对头文件自检:每个声明都有定义,定义顺序与声明顺序一致;新增或改动的函数按同一套分段约定,需要分阶段的都有阶段注释与空行;只改过语言细节时再过对应目录的完成清单(`references/language/value-types/11-checklist.md`、`language-basics/10-checklist.md`、`standard-library/10-checklist.md`、`performance/07-checklist.md`);行宽与缩进以工程根 `.clang-format` 为准,注释版式见 `references/comments/
|
|
39
|
+
实现改完,先对照配对头文件自检:每个声明都有定义,定义顺序与声明顺序一致;新增或改动的函数按同一套分段约定,需要分阶段的都有阶段注释与空行;只改过语言细节时再过对应目录的完成清单(`references/language/value-types/11-checklist.md`、`language-basics/10-language-checklist.md`、`standard-library/10-library-checklist.md`、`performance/07-checklist.md`);行宽与缩进以工程根 `.clang-format` 为准,注释版式见 `references/comments/02-style.md`。再跑 `node <skill-dir>/scripts/checking-declaration-order.mjs --root .`(`<skill-dir>` 换成插件 `developing-cpp` 的实际目录),有乱序先修再交回下游:需要新增或移动源文件时,先由 `engineering` 的 `steps/01-targets.md` 把文件显式写进 target;target 齐了再由 `building-cpp` 的 `steps/01-build.md` configure、构建,最后走 `steps/03-check.md`。不要只改完函数体就宣称完成。
|
|
40
40
|
|
|
41
41
|
## 正反例指针
|
|
42
42
|
|
|
43
|
-
- 实现注释复述代码、分组混乱:`references/comments/examples/implementation-body.md`。
|
|
43
|
+
- 实现注释复述代码、分组混乱:`references/comments/examples/09-implementation-body.md`。
|
|
44
44
|
- 已经证明非负的坐标把下标收成 `std::size_t` 再 `[]`,不转成 `int`:`references/language/value-types/09-subscript.md`。
|
|
45
|
-
- 越界消息的函数名、文件与行列都取自调用点:`references/exceptions/
|
|
46
|
-
- 多个入口重复同一范围检查:抽私有函数,`source_location` 默认参数取调用点,见 `references/exceptions/
|
|
47
|
-
- 为了保住 `noexcept` 再包一层只转发下标的私有函数:`references/exceptions/
|
|
48
|
-
- 用 `static_cast<void>` 丢弃 `[[nodiscard]]` 的落子结果,或丢掉调用方给的一手、在 `Game` 内重新拼装:`references/design/examples/move-result.md`。
|
|
49
|
-
- 异常类型与结果类型混用:`references/exceptions/examples/throw-when.md`。
|
|
50
|
-
- `std::format` 与流输出混用得当:`references/exceptions/examples/throw-message.md`。
|
|
45
|
+
- 越界消息的函数名、文件与行列都取自调用点:`references/exceptions/01-exception-rules.md`「消息」的 `std::source_location` 用法。
|
|
46
|
+
- 多个入口重复同一范围检查:抽私有函数,`source_location` 默认参数取调用点,见 `references/exceptions/01-exception-rules.md`「重复的入口检查」。
|
|
47
|
+
- 为了保住 `noexcept` 再包一层只转发下标的私有函数:`references/exceptions/01-exception-rules.md`「不抛的边界」。
|
|
48
|
+
- 用 `static_cast<void>` 丢弃 `[[nodiscard]]` 的落子结果,或丢掉调用方给的一手、在 `Game` 内重新拼装:`references/design/examples/06-move-result.md`。
|
|
49
|
+
- 异常类型与结果类型混用:`references/exceptions/examples/07-throw-when.md`。
|
|
50
|
+
- `std::format` 与流输出混用得当:`references/exceptions/examples/06-throw-message.md`。
|
|
@@ -7,7 +7,7 @@ metadata:
|
|
|
7
7
|
|
|
8
8
|
# engineering
|
|
9
9
|
|
|
10
|
-
本技能管两件事:CMake 文件与 target 契约,以及编码与排版工具配置。函数体、类型、命名、异常与源码注释只开 `developing-cpp`;构建目录、编译器、入口脚本与运行检查开 `building-cpp
|
|
10
|
+
本技能管两件事:CMake 文件与 target 契约,以及编码与排版工具配置。函数体、类型、命名、异常与源码注释只开 `developing-cpp`;构建目录、编译器、入口脚本与运行检查开 `building-cpp`。加载顺序与层表见 [budget.md](../shared/budget.md)。
|
|
11
11
|
|
|
12
12
|
## 适用场景
|
|
13
13
|
|
|
@@ -19,7 +19,7 @@ metadata:
|
|
|
19
19
|
|
|
20
20
|
## 三种操作
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
一次只选一种操作,范围(单点、整段)是任务属性;判据、边界与交接见共用入口 [operations.md](../shared/operations.md)。本技能从 [01-targets.md](steps/01-targets.md) 进;四类改动是域,不是操作。
|
|
23
23
|
|
|
24
24
|
| 操作 | 什么时候用 | 从哪步进 |
|
|
25
25
|
| --- | --- | --- |
|
|
@@ -46,28 +46,28 @@ metadata:
|
|
|
46
46
|
|
|
47
47
|
| 要做的事 | 打开 |
|
|
48
48
|
| --- | --- |
|
|
49
|
-
|
|
|
50
|
-
|
|
|
51
|
-
|
|
|
49
|
+
| 不知道开哪一份条文 | `references/index.md` |
|
|
50
|
+
| 定 target、include、链接、输出目录与警告 | `references/cmake/targets/01-target-rules.md`;案例在 `references/cmake/targets/examples/` |
|
|
51
|
+
| 定语言标准与档位 | `references/cmake/standards/01-cxx-standard.md`;五档细节在 `references/cmake/standards/versions.md` |
|
|
52
|
+
| 抽 CMake 函数与模块 | `references/cmake/modules/01-functions.md` |
|
|
52
53
|
| 链接方式、rpath、undefined reference、产物核对 | 按问题只开一份:`references/cmake/linking/01-libraries.md`、`02-rpath.md`、`03-undefined-reference.md`、`04-inspect.md` |
|
|
53
|
-
| CTest 注册、断言与用例拆分 | `references/cmake/testing/ctest.md` |
|
|
54
|
+
| CTest 注册、断言与用例拆分 | `references/cmake/testing/01-ctest.md` |
|
|
54
55
|
| 编码、BOM 与行尾 | `references/formatting/01-encoding.md` |
|
|
55
|
-
| clang-format | `references/formatting/02-clang-format.md`;案例 `references/formatting/examples/clang-format.md` |
|
|
56
|
-
| clang-tidy 与检查分级 | `references/formatting/03-clang-tidy.md`;案例 `references/formatting/examples/clang-tidy.md` |
|
|
57
|
-
| clangd 与编辑器补全 | `references/formatting/04-clangd.md`;案例 `references/formatting/examples/clangd.md` |
|
|
56
|
+
| clang-format | `references/formatting/02-clang-format.md`;案例 `references/formatting/examples/01-clang-format.md` |
|
|
57
|
+
| clang-tidy 与检查分级 | `references/formatting/03-clang-tidy.md`;案例 `references/formatting/examples/02-clang-tidy.md` |
|
|
58
|
+
| clangd 与编辑器补全 | `references/formatting/04-clangd.md`;案例 `references/formatting/examples/03-clangd.md` |
|
|
58
59
|
| 可复制的 CMake 函数 | `references/cmake/assets/CompileSettings.cmake`、`references/cmake/assets/LinkSettings.cmake` |
|
|
60
|
+
| 操作判不准、规则冲突 | `../shared/operations.md`、`../shared/rule-priority.md` |
|
|
59
61
|
|
|
60
62
|
## 加载预算
|
|
61
63
|
|
|
62
|
-
|
|
63
|
-
- 条文只开该步点名的一份;同号案例留到下一次激活;target 案例先列 `references/cmake/targets/examples/`,再按问题选一份;排版工具一次只开入口表里的那一份。
|
|
64
|
-
- 标准档只打开项目技能声明的那一档,没有声明时用本技能已有的新工程默认,不把其余标准档读进来。
|
|
64
|
+
加载预算见 [budget.md](../shared/budget.md);engineering 的步骤固定 3 份。
|
|
65
65
|
|
|
66
66
|
项目技能列出了检查命令时只跑那一条,没有时按 `steps/03-check.md` 的 configure 与构建命令跑;退出码为 0 后停在这一步,不再继续走没有失败的步骤。五档标准的语言设施、工具映射与降档由 `references/cmake/standards/` 维护;本技能只负责这些标准在 CMake 里怎么写,以及三份工具配置各自的最低版本。
|
|
67
67
|
|
|
68
68
|
## 四类改动
|
|
69
69
|
|
|
70
|
-
四类改动是操作内部的域:操作定入口,域定层次。四域的定义、边界与次序见
|
|
70
|
+
四类改动是操作内部的域:操作定入口,域定层次。四域的定义、边界与次序见 [operations.md](../shared/operations.md);engineering 的一次改动混了两类时,按「内容 → 结构 → 版式 → 措辞」拆开做,前一类落定并经检查再进下一类。
|
|
71
71
|
|
|
72
72
|
| 类型 | 典型请求 | 入口步骤 |
|
|
73
73
|
| --- | --- | --- |
|
|
@@ -81,7 +81,7 @@ metadata:
|
|
|
81
81
|
- [ ] target 图显式:程序 target 叫 `app`,库 target 用组件名,程序链接库,库的公共 include 用 `PUBLIC`;没有全局 include、全局编译选项或 GLOB。
|
|
82
82
|
- [ ] 每个 target 的标准来自 `environment.json`;`target_compile_features` 与 `CXX_STANDARD`、`CXX_STANDARD_REQUIRED ON`、`CXX_EXTENSIONS OFF` 同时存在,live 的 `compile_commands.json` 中每个 target 的 `-std=` 都与声明一致,且每个 target 只有一条、不同值即失败,不是 `gnu++NN`。
|
|
83
83
|
- [ ] 复用的 CMake 函数放在工程根的 `cmake/` 模块里(模板源在 `references/cmake/assets/`),文件名用 UpperCamelCase,函数名用 `<ModuleName>_` 加 PascalCase,有目标与参数校验,根 `CMakeLists.txt` 通过 `CMAKE_MODULE_PATH` 导入;没有重复片段和未使用的旧模块。
|
|
84
|
-
- [ ] 公开函数上方写中文 `#` 契约:一句功能、空行、边界,再用 `:param` / `:keyword` 标参数;不写 `#[[.rst:` 与 `.. command::`,完整写法见 `references/cmake/targets/rules.md`;函数组之间用 `#---`,不画 `#===...===#` 方框。
|
|
84
|
+
- [ ] 公开函数上方写中文 `#` 契约:一句功能、空行、边界,再用 `:param` / `:keyword` 标参数;不写 `#[[.rst:` 与 `.. command::`,完整写法见 `references/cmake/targets/01-target-rules.md`;函数组之间用 `#---`,不画 `#===...===#` 方框。
|
|
85
85
|
- [ ] `CMakeLists.txt` 与 `*.cmake` 用 UTF-8 无 BOM、LF、2 空格缩进、不用 tab;行宽按团队约定,默认 80 列。
|
|
86
86
|
- [ ] 编码与排版工具各管一段:`.clang-format` 管空白与包含顺序,`.clang-tidy` 管检查分级,`.clangd` 管编辑器补全;三份都不把标准写死成与 `environment.json` 冲突的值,也不把 clang-format 塞进构建脚本。
|
|
87
87
|
- [ ] configure 与构建通过,构建产物不落在源码目录;没有改源码语义,也没有覆盖已有工程文件。
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
<!-- 读取时机:配 CMake 或工具链时;读完能回答:链接与库边界;预算:一次只开这一份(62 行),不自动串联。 -->
|
|
1
2
|
# 链接与库边界
|
|
2
3
|
|
|
3
4
|
## 四个阶段
|
|
@@ -21,7 +22,7 @@
|
|
|
21
22
|
- 普通函数的定义放 `.cpp`;在头文件里写非 `inline` 函数定义,多个翻译单元包含时会重复定义。
|
|
22
23
|
- 类定义放头文件;成员函数在类外定义时写 `ClassName::`,定义放 `.cpp`。
|
|
23
24
|
- 只用到声明时不要包含完整定义;前置声明可以减少编译依赖,但不能替代需要完整类型的场景(继承、成员对象、按值返回)。
|
|
24
|
-
- 每个头文件自包含:单独编译一个只包含该头文件的 `.cpp`
|
|
25
|
+
- 每个头文件自包含:单独编译一个只包含该头文件的 `.cpp` 应通过。这是编译单元边界的要求,不是链接要求。用路径式 `#define` 守卫防止重复包含,不用 `#pragma once`。
|
|
25
26
|
|
|
26
27
|
## 静态库与共享库
|
|
27
28
|
|
|
@@ -35,13 +36,15 @@
|
|
|
35
36
|
- 共享库的 ABI 包括类布局、虚表、标准库类型和编译器选项;不同编译器或 `-stdlib` 混用可能链接成功但运行崩溃。
|
|
36
37
|
- 一个项目里不要同时链接两套标准库(libstdc++ 与 libc++);编译器、clangd、库和可执行文件必须一致。
|
|
37
38
|
|
|
38
|
-
##
|
|
39
|
+
## 构建脚本里的建议顺序
|
|
40
|
+
|
|
41
|
+
这是构建入口的推荐顺序,不是链接器的硬性要求:
|
|
39
42
|
|
|
40
43
|
1. 配置:CMake 生成构建系统,导出编译数据库。
|
|
41
44
|
2. 编译 + 链接:构建所有 target。
|
|
42
45
|
3. 产物检查:确认 `bin/app`、`lib/`、编译数据库存在。
|
|
43
|
-
4.
|
|
44
|
-
5.
|
|
46
|
+
4. 测试:`ctest` 跑注册的测试。
|
|
47
|
+
5. 运行:用项目入口命令启动,检查退出码和输出。
|
|
45
48
|
|
|
46
49
|
不要用“链接成功”代替“运行成功”;也不要用“测试通过”代替“产物存在”。
|
|
47
50
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
<!-- 读取时机:配 CMake 或工具链时;读完能回答:undefined reference 分诊;预算:一次只开这一份(20 行),不自动串联。 -->
|
|
1
2
|
# undefined reference 分诊
|
|
2
3
|
|
|
3
4
|
## `undefined reference` 分诊
|
|
@@ -6,7 +7,7 @@
|
|
|
6
7
|
| --- | --- | --- |
|
|
7
8
|
| 链接器说某个成员函数未定义 | 声明了但没写定义,或 `.cpp` 没加入 target | 补定义,或把源文件加入 `target_sources` |
|
|
8
9
|
| 只有某个平台失败 | 条件编译把定义排除了 | 检查宏和平台分支,保证每个平台都有定义 |
|
|
9
|
-
| 第三方库符号缺失 |
|
|
10
|
+
| 第三方库符号缺失 | 没链接库,或静态库相互依赖顺序不对 | `target_link_libraries` 加库;CMake 传播 target 依赖,静态库相互依赖时仍要检查顺序 |
|
|
10
11
|
| C++ 符号被当成 C 符号 | 头文件缺少 `extern "C"` | C 接口头加 `extern "C"`,C++ 调用方也可见 |
|
|
11
12
|
| 模板成员未定义 | 模板定义在 `.cpp`,实例化点看不到 | 模板定义移到头文件,或显式实例化 |
|
|
12
13
|
| 静态库中的目标文件没被拉入 | 链接器只取被引用符号所在的目标文件 | 确认符号确实被引用,或改用对象库/共享库 |
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
<!-- 读取时机:配 CMake 或工具链时;读完能回答:验收:file 与 ldd;预算:一次只开这一份(20 行),不自动串联。 -->
|
|
1
2
|
# 验收:file 与 ldd
|
|
2
3
|
|
|
3
4
|
## 验收:`file` 与 `ldd`
|
|
@@ -18,4 +19,3 @@ ldd build/clang/bin/app
|
|
|
18
19
|
|
|
19
20
|
- [`file(1)`](https://man7.org/linux/man-pages/man1/file.1.html):识别文件格式、架构与位数。
|
|
20
21
|
- [`ldd(1)`](https://man7.org/linux/man-pages/man1/ldd.1.html):动态库依赖解析与 `not found` 的含义。
|
|
21
|
-
- [CMake: `add_custom_command`](https://cmake.org/cmake/help/latest/command/add_custom_command.html):把产物检查接进构建流程。
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
<!-- 读取时机:配 CMake 或工具链时;读完能回答:CMake 模块与函数;预算:一次只开这一份(108 行),不自动串联。 -->
|
|
1
2
|
# CMake 模块与函数
|
|
2
3
|
|
|
3
4
|
目标:同一段构建逻辑只有一份权威,函数可导入、可校验、可测试,目标目录只表达差异。
|
|
@@ -22,7 +23,7 @@ project/
|
|
|
22
23
|
LinkSettings.cmake
|
|
23
24
|
component/
|
|
24
25
|
CMakeLists.txt
|
|
25
|
-
|
|
26
|
+
app/
|
|
26
27
|
CMakeLists.txt
|
|
27
28
|
```
|
|
28
29
|
|
|
@@ -75,7 +76,7 @@ endfunction()
|
|
|
75
76
|
|
|
76
77
|
## 契约注释
|
|
77
78
|
|
|
78
|
-
公开函数上方写中文 `#` 契约:一句功能、空行、边界,再用 `:param` 标位置参数、`:keyword` 标关键字参数;不写 `#[[.rst:` 与 `.. command::`,那是进 CMake 手册的模块才用的标记。同一文件的函数组之间用一条 `#---` 分隔,行注释只写原因,不画 `#===...===#` 方框。完整写法见 `../targets/rules.md`。
|
|
79
|
+
公开函数上方写中文 `#` 契约:一句功能、空行、边界,再用 `:param` 标位置参数、`:keyword` 标关键字参数;不写 `#[[.rst:` 与 `.. command::`,那是进 CMake 手册的模块才用的标记。同一文件的函数组之间用一条 `#---` 分隔,行注释只写原因,不画 `#===...===#` 方框。完整写法见 `../targets/01-target-rules.md`。
|
|
79
80
|
|
|
80
81
|
## 测试
|
|
81
82
|
|
package/skills/engineering/references/cmake/standards/{cxx-standard.md → 01-cxx-standard.md}
RENAMED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
<!-- 读取时机:配 CMake 或工具链时;读完能回答:C++ 标准与 CMake;预算:一次只开这一份(68 行),不自动串联。 -->
|
|
1
2
|
# C++ 标准与 CMake
|
|
2
3
|
|
|
3
4
|
目标:一个 target 只声明一个标准,声明在 target 上,编译数据库里的实际参数与声明一致。
|
|
@@ -11,8 +12,8 @@ CMake 有两套相关机制,必须同时写:
|
|
|
11
12
|
|
|
12
13
|
| `standard` | meta-feature | `CXX_STANDARD` | `__cplusplus` | CMake 最低版本 |
|
|
13
14
|
| --- | --- | --- | --- | --- |
|
|
14
|
-
| `c++11` | `cxx_std_11` | `11` | `201103L` | 3.
|
|
15
|
-
| `c++14` | `cxx_std_14` | `14` | `201402L` | 3.
|
|
15
|
+
| `c++11` | `cxx_std_11` | `11` | `201103L` | 3.1 |
|
|
16
|
+
| `c++14` | `cxx_std_14` | `14` | `201402L` | 3.1 |
|
|
16
17
|
| `c++17` | `cxx_std_17` | `17` | `201703L` | 3.8 |
|
|
17
18
|
| `c++20` | `cxx_std_20` | `20` | `202002L` | 3.12 |
|
|
18
19
|
| `c++23` | `cxx_std_23` | `23` | `202302L` | 3.20 |
|
package/skills/engineering/references/cmake/standards/examples/{standard.md → 01-standard.md}
RENAMED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
<!-- 读取时机:配 CMake 或工具链时;读完能回答:正反例:标准只写一半;预算:一次只开这一份(19 行),不自动串联。 -->
|
|
1
2
|
# 正反例:标准只写一半
|
|
2
3
|
|
|
3
4
|
**差**:
|
|
@@ -8,7 +9,7 @@ target_compile_features(app PRIVATE cxx_std_20)
|
|
|
8
9
|
set_target_properties(app PROPERTIES CXX_STANDARD 20)
|
|
9
10
|
```
|
|
10
11
|
|
|
11
|
-
问题:meta-feature 只保证“至少”,`CXX_STANDARD`
|
|
12
|
+
问题:meta-feature 只保证“至少”,`CXX_STANDARD` 又允许静默降级,实际标准可能不是 20。
|
|
12
13
|
|
|
13
14
|
**好**:
|
|
14
15
|
|