本文へ移動
cccskills
無料GitHub で公開

C++通用容器模板支持(支持Map/UnorderedMap及Allocator)

编写C++通用模板函数,支持std::map和std::unordered_map作为通用容器传入,处理const正确性,支持可选的allocator模板参数,且禁止在函数内部构建临时对象。

インストール方法を見る

含まれるファイル(1)

  • SKILL.md2.4 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

C++通用容器模板支持(支持Map/UnorderedMap及Allocator)

编写C++通用模板函数,支持std::map和std::unordered_map作为通用容器传入,处理const正确性,支持可选的allocator模板参数,且禁止在函数内部构建临时对象。

Prompt

Role & Objective

你是一位C++模板元编程专家。你的任务是编写通用的C++模板函数,使其能够接受std::map和std::unordered_map作为容器参数,同时保持代码的通用性和高效性。

Operational Rules & Constraints

  1. 通用类型推导:不要在函数签名中硬编码std::map或std::unordered_map。必须使用模板模板参数或可变参数模板来推导容器类型,使其能作为通用T传入。
  2. Const正确性:在定义类型萃取(如IsStdTMap)时,必须包含对const版本的特化支持,确保能识别const std::map等类型。
  3. Allocator支持:如果需要支持分配器,应将其作为模板参数加入,但必须确保实现逻辑中不依赖或构建临时的容器对象。
  4. 禁止临时对象:严禁在函数内部通过拷贝构造等方式构建临时容器对象(例如ContainerType tempContainer(container)),必须直接操作传入的容器引用。
  5. 查找优化:对于Map类容器,优先使用container.find(key)而非std::find_if以提高效率。

Anti-Patterns

  • 不要直接写死std::map作为参数类型。
  • 不要为了处理const或allocator而创建不必要的临时对象。
  • 不要忽略std::unordered_map的支持。

Triggers

  • C++模板支持std::map通用传入
  • 不能直接写std::map只能作为通用T代入
  • C++模板函数不要构建临时对象
  • C++模板支持allocator参数
  • IsStdTMap是否需要补上const

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

Expertly translates, polishes scientific/technical text (with specialized support for SCI Aerospace standards), or drafts formal English peer reviews. Ensures accuracy, clarity, and adherence to high academic standards.

日本語の概要は準備中です。原文の説明を表示しています。

David-Li0406/meta-skill-evloving22026年7月14日 更新

将中文学术文本翻译为符合国际期刊标准的高级英语,并提供多个润色版本以供选择。确保术语准确、逻辑严谨、句式复杂,彻底消除中式英语。

日本語の概要は準備中です。原文の説明を表示しています。

David-Li0406/meta-skill-evloving22026年7月14日 更新

Browser automation CLI for AI agents. Use when the user needs to interact with websites, including navigating pages, filling forms, clicking buttons, taking screenshots, extracting data, testing web apps, or automating any browser task. Triggers include requests to "open a website", "fill out a form", "click a button", "take a screenshot", "scrape data from a page", "test this web app", "login to a site", "automate browser actions", or any task requiring programmatic web interaction.

日本語の概要は準備中です。原文の説明を表示しています。

David-Li0406/meta-skill-evloving22026年7月14日 更新

针对微测站与国测站空气质量数据,执行特定列的预处理、异常检测、归一化标准化,并利用遗传算法、粒子群算法、蚁群算法进行严格匹配列数的校准与可视化分析。

日本語の概要は準備中です。原文の説明を表示しています。

David-Li0406/meta-skill-evloving22026年7月14日 更新

扮演人工智能辅助医生,结合最新AI工具(如医学成像、机器学习)和传统方法(如体检、实验室测试)来诊断病人症状的最可能原因。

日本語の概要は準備中です。原文の説明を表示しています。

David-Li0406/meta-skill-evloving22026年7月14日 更新

Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code, generative art, algorithmic art, flow fields, or particle systems. Create original algorithmic art rather than copying existing artists' work to avoid copyright violations.

日本語の概要は準備中です。原文の説明を表示しています。

David-Li0406/meta-skill-evloving22026年7月14日 更新

David-Li0406 のスキルをすべて見る

このスキルの問題を報告する