본문으로 건너뛰기
cccskills
무료GitHub에 공개

cpp-templates

Use when a C++ template error needs decoding, a template needs a concept or requires-clause instead of SFINAE, or template instantiation is slowing compilation. Not for C++20 modules: use cpp-modules.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(2)

  • SKILL.md5.4 KB
  • agents/openai.yaml227 B

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

C++ templates

Contract

FieldBound contract
TriggerThe user shows a long template error, asks how to constrain a template, asks SFINAE versus concepts, or reports that template-heavy translation units compile slowly.
AuthorityRead-only. The skill emits readings, constraint rewrites, and profiling commands to chat; the user edits the code. Rollback is not needed. No remote mutation.
Side effectChat output. Profiling commands write trace files where the user runs them.
DoneThe failing instantiation is named with the substitution that failed, the proposed constraint compiles on the user's standard, and any compile-time claim carries a measurement command.

Inputs

  • Compiler, version, and -std=: required. Concepts need C++20; C++23 is the current standard and C++20 the floor.
  • The full diagnostic text: required for error reading.
  • The template and one call site: required for constraint work.
  • A build with compile_commands.json or a single reproducing TU: required for profiling.

Procedure

  1. Read the error from the bottom up. The first error: line names the user's call; the required from here (GCC) or in instantiation of (Clang) notes trace the chain; the last note names the type whose substitution failed. Shorten the chain with -ftemplate-backtrace-limit=N (GCC and Clang); with GCC add -fconcepts-diagnostics-depth=N for concept failures; with Clang add -fno-elide-type to print full types and -fdiagnostics-show-template-tree for a tree diff of the mismatch. Done when: the failing substitution and the call site are named.

  2. Write the constraint with concepts when the standard is C++20 or later:

    template <typename T> concept Arithmetic = std::is_arithmetic_v<T>;
    template <typename T> concept Container = requires(T c) {
        c.begin(); c.end(); c.size(); typename T::value_type;
    };
    template <Arithmetic T> T square(T x) { return x * x; }
    auto square(Arithmetic auto x) { return x * x; }
    template <typename T> requires Arithmetic<T> && (sizeof(T) >= 4)
    T big_square(T x) { return x * x; }
    

    Requires-expression forms: expr; checks validity, { expr } -> std::same_as<U>; checks the result type, { expr } -> std::convertible_to<U>; checks convertibility, requires Other<T>; nests a constraint. Done when: the constraint expresses the operations the body uses and nothing more.

  3. Recognize SFINAE in existing code and map it to a concept: std::enable_if_t<cond, int> = 0 on a parameter, -> std::enable_if_t<cond, R> on a return type, and the std::void_t<decltype(...)> detection idiom. Replace enable_if with a constraint and void_t detectors with a requires expression. Keep SFINAE only when the standard is below C++20. Done when: each SFINAE site has its concept equivalent or a reason to keep it.

  4. Explain the trade-off when asked. Concepts give a named constraint failure at the call site, participate in overload ranking by subsumption, and read directly; SFINAE gives a wall of candidate notes and ranks by hand-built priority. Compile-time differences depend on the code; measure before claiming one. Done when: the comparison is stated without unmeasured speed claims.

  5. Profile instantiation cost. Clang: -ftime-trace writes <object>.json per TU; aggregate a whole build with ClangBuildAnalyzer --start <dir>, build, ClangBuildAnalyzer --stop <dir> capture.bin, ClangBuildAnalyzer --analyze capture.bin, which lists the templates and template sets that took longest to instantiate. Templight, a Clang-based drop-in, traces every instantiation: templight++ -Xtemplight -profiler -Xtemplight -memory -Xtemplight -ignore-system -c src.cpp writes src.o.trace.pbf; it must be built from source with Clang. Done when: a measurement names the top instantiations.

  6. Reduce the measured cost with the pattern that fits: explicit instantiation (extern template int f<int>(int); in the header, template int f<int>(int); in one TU); if constexpr in place of specialization; a constraint that rejects early instead of a deep substitution failure; splitting heavy template implementations into a header included only where needed. Done when: each proposed change is tied to an instantiation the profile named.

  7. Confirm the rewrite compiles on the user's compiler and standard with a scratch TU before reporting. Done when: the scratch build passes.

Failure and recovery

Failure classBehavior
Standard below C++20Concepts unavailable; keep SFINAE and shorten diagnostics with the backtrace flags.
Diagnostic truncated by the userAsk for the full output or reproduce it; do not guess the failing type.
ClangBuildAnalyzer or Templight absentFall back to per-TU -ftime-trace and read the JSON with a trace viewer.
Slowness is not instantiationIf the profile names headers or codegen, redirect: caching and PCH belong to build-acceleration.
Coroutine template questionC++20 coroutines: use cpp-coroutines.

Output

A chat report naming the failing instantiation and its cause, the constraint rewrite that compiled on a scratch TU, and, when compile time was the complaint, the measurement command and the instantiations it named with the matching reduction.

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Use when explaining System V AMD64, ARM AAPCS, RISC-V psABI, stack frames, variadic calls, or FFI register rules. Not for the Rust FFI binding layer: use rust-ffi.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

OutlineDriven/odin-claude-plugin372026년 9월 29일 업데이트

Use when configuring ADC sampling time, DMA-driven ADC, calibration, or DAC channel setup on bare-metal MCUs. Not for the DMA stream itself: use dma-baremetal.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

OutlineDriven/odin-claude-plugin372026년 9월 29일 업데이트

af-xdp

무료

Use when creating AF_XDP sockets, configuring UMEM and XSK rings, writing an XDP redirect program, or choosing copy versus zero-copy mode. Not for full kernel bypass: use dpdk.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

OutlineDriven/odin-claude-plugin372026년 9월 29일 업데이트

Use when a completed session needs an agent-environment retrospective. Not for an engineering retrospective from telemetry: use engineering-retrospective.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

OutlineDriven/odin-claude-plugin372026년 9월 29일 업데이트

Use when a redacted, trimmed agent transcript must be appended to a GitHub PR or issue body, with human approval and preview. Not for automated or model-initiated insertion.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

OutlineDriven/odin-claude-plugin372026년 9월 29일 업데이트

agents-md

무료

Use when a repo needs agent setup, AGENTS.md added or made lean, CLAUDE.md audited, or agent instructions scored or pruned. Not for remote, credential, publish, deploy, or irreversible changes.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

OutlineDriven/odin-claude-plugin372026년 9월 29일 업데이트

OutlineDriven의 스킬 모두 보기

이 스킬의 문제 신고