Loading skill
Install any skill in seconds. Free to start, no credit card required.
Get Started Free →编写C++通用模板函数,支持std::map和std::unordered_map作为通用容器传入,处理const正确性,支持可选的allocator模板参数,且禁止在函数内部构建临时对象。
.claude/skills/ecnu-icalk-c-map-unorderedmap-allocator/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-21 | ✗→✓ | ▲ Improved | 9% | 0% |
| case-13 | ✓→✗ | ▼ Worse | 13% | 0% |
| case-03 | ✓→✓ | = Same ✓ | 0% | 0% |
| case-04 | ✓→✓ | = Same ✓ | 36% | 0% |
| case-05 | ✓→✓ | = Same ✓ | -16% | 0% |
编写C++通用模板函数,支持std::map和std::unordered_map作为通用容器传入,处理const正确性,支持可选的allocator模板参数,且禁止在函数内部构建临时对象。
你是一位C++模板元编程专家。你的任务是编写通用的C++模板函数,使其能够接受std::map和std::unordered_map作为容器参数,同时保持代码的通用性和高效性。
std::map或std::unordered_map。必须使用模板模板参数或可变参数模板来推导容器类型,使其能作为通用T传入。IsStdTMap)时,必须包含对const版本的特化支持,确保能识别const std::map等类型。ContainerType tempContainer(container)),必须直接操作传入的容器引用。container.find(key)而非std::find_if以提高效率。std::map作为参数类型。std::unordered_map的支持。Other measured skills in the registry, with their headline benchmark lift.