C++
knowledge skill
The agent writes or refactors C++ source code to satisfy a concrete programming task, producing a compilable code file or snippet that adheres to the specified language standard. It returns the generated code together with brief compile instructions and any relevant remarks.
Worked examples
- {"input": {"task_description": "Implement a thread\u2011safe singleton class using C++17", "target_standard": "c++17", "filename": "Singleton.h"}, "output": {"code": "#pragma once\n#include <mutex>\n\nclass Singleton {\npublic:\n static Singleton& instance() {\n static Singleton s;\n return s;\n }\n Singleton(const Singleton&) = delete;\n Singleton& operator=(const Singleton&) = delete;\nprivate:\n Singleton() = default;\n static std::once_flag initFlag;\n};\n", "compile_instructions": "g++ -std=c++17 -c Singleton.h", "notes": "Uses function\u2011local static for thread\u2011safe initialization per C++11/17 guarantee."}}
- {"input": {"task_description": "Refactor the given function to use std::ranges for filtering even numbers", "target_standard": "c++20", "filename": "filter.cpp", "existing_code": "#include <vector>\n#include <algorithm>\n\nstd::vector<int> get_even(const std::vector<int>& v) {\n std::vector<int> result;\n std::copy_if(v.begin(), v.end(), std::back_inserter(result), [](int x){ return x % 2 == 0; });\n return result;\n}"}, "output": {"code": "#include <vector>\n#include <ranges>\n\nstd::vector<int> get_even(const std::vector<int>& v) {\n return v | std::views::filter([](int x){ return x % 2 == 0; }) | std::ranges::to<std::vector>();\n}\n", "compile_instructions": "g++ -std=c++20 -c filter.cpp", "notes": "Replaced copy_if with std::ranges pipeline; requires <ranges> and C++20."}}
Input
- task_description: string – brief description of the programming goal
- target_standard: string – C++ language version (e.g., c++17, c++20)
- filename: string – desired name for the output file
- existing_code: string – optional original code to be modified
Output
- code: string – the complete C++ source content
- compile_instructions: string – command line needed to compile the file
- notes: string – short remarks about the implementation or changes
Details
- Skill type: knowledge skill
- Safety level: safe_public_research
- Version: 1.0.0