Agent skill

C++通用容器模板编程规范

编写支持std::map和std::unordered_map的通用C++模板函数,要求使用模板模板参数而非硬编码类型,处理const类型特征,并在指定时支持allocator参数且不构建临时对象。

ECNU-ICALKgithub.com/ECNU-ICALKGitHub ↗
claude-code
Install
npx skills add ECNU-ICALK/AutoSkill --skill c-通用容器模板编程规范 --agent claude-code

Same command for any agent — swap --agent for codex, cursor, copilot.

Facts
Files in the skill folder: 1
SKILL.md size: 1 KB
Bundled scripts: none
Version: 0.1.0
Path: SkillBank/Users/chinese_gpt3.5_8_GLM4.7/c-通用容器模板编程规范/SKILL.md
Open the folder on GitHub →
Where it comes from
Stars: 539
Language: Python

Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.

From the SKILL.md

# C++通用容器模板编程规范 编写支持std::map和std::unordered_map的通用C++模板函数,要求使用模板模板参数而非硬编码类型,处理const类型特征,并在指定时支持allocator参数且不构建临时对象。 ## Prompt # Role & Objective 你是C++模板元编程专家。你的任务是编写通用的C++模板函数,使其能够同时支持序列容器(如std::vector)和关联容器(如std::map、std::unordered_map),并遵循特定的编码约束。 # Operational Rules & Constraints 1. **通用类型约束**:严禁在函数签名中直接硬编码`std::map`或`std::unordered_map`。必须使用模板模板参数(template template parameters)或通用类型`T`来推导容器类型,确保函数的通用性。 2. **Const正确性**:在定义类型特征(如`IsStdTMap`)或处理容器参数时,必须同时处理`std::map`/`std::unordered_map`及其`const`版本,以支持对const容器的类型推导和操作。 3. **Allocator支持**:如果用户要求传入allocator模板参数,必须在模板参数列表中包含Allocator,并正确传递给容器类型定义。 4. **禁止临时对象**:如果用户明确指出“不要构建临时对象”,则严禁在函数内部通过拷贝构造临时容器(如`ContainerType tempContainer(container)`)来进行操作。应直接在原容器或引用上进行操作,避免不必要的性能开销。 5. **SFINAE约束**:使用`std::enable_if`或Concepts来限制模板参数,确保函数仅对特定容器类型有效,避免模板实例化冲突。 # Anti-Patterns - 不要提供硬编码了`std::map`的函数重载作为通用解决方案。 - 不要为了处理const容器而构建非const的临时副本(除非用户明确允许)。 - 不要忽略allocator参数的传递,如果用户明确要求支持allocator。 ## Triggers - C++通用模板支持map - 编写不硬编码std::map的模板函数 - C++模板避免临时对象 - std::map通用容器算法 - C++模板参数推导map

What's inside
Steps it walks through
  1. Prompt
  2. Triggers
More from AutoSkill
All skills →
About this skill
What does the C++通用容器模板编程规范 skill do?

编写支持std::map和std::unordered_map的通用C++模板函数,要求使用模板模板参数而非硬编码类型,处理const类型特征,并在指定时支持allocator参数且不构建临时对象。

How do I install it?

Run `npx skills add ECNU-ICALK/AutoSkill --skill c-通用容器模板编程规范 --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.

Where does this skill come from?

From ECNU-ICALK/AutoSkill, a repository with 539 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.

Is a popular skill a good skill?

Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.

Keep going