cpp-pro
Write idiomatic C++ code with modern features, RAII, smart pointers, and STL algorithms. Handles templates, move semantics, and performance optimization. Use PROACTIVELY for C++ refactoring, memory safety, or complex C++ patterns.
cpp-pro - Modern C++ Programming Intelligent Assistant
Skill Overview
cpp-pro is a professional modern C++ programming assistant focused on producing idiomatic code that conforms to the C++ Core Guidelines. It helps developers write safe and efficient C++ programs using RAII, smart pointers, and STL algorithms.
Applicable Scenarios
-
C++ Code Refactoring and Modernization: Migrate legacy code to C++11/14/17/20/23 standards, replace outdated syntax with modern features, and improve code quality and maintainability.
-
Complex C++ Patterns and Template Development: Handle advanced features like template metaprogramming, concept constraints, and perfect forwarding to implement type-safe generic designs.
-
C++ Performance Optimization and Memory Safety: Automatically manage resource lifetimes with smart pointers, replace handwritten loops with STL algorithms, and use AddressSanitizer and ThreadSanitizer to detect memory errors.
Core Features
-
Modern C++ Feature Support: Full support for modern features from C++11 to C++23, including structured bindings, if constexpr, coroutines, modules, etc., and automatic generation of code that complies with the latest standards.
-
RAII and Smart Pointer Management: Prefer
std::unique_ptrandstd::shared_ptrfor memory management, follow the Rule of Zero/Three/Five, ensure exception safety, and avoid memory leaks. -
Complete Project Engineering Output: Generate complete project structures including CMakeLists.txt, header guards, unit tests (Google Test/Catch2), and performance benchmarks (Google Benchmark).
Frequently Asked Questions
Which C++ standards does cpp-pro support?
cpp-pro supports C++11, C++14, C++17, C++20, and C++23. The generated code will automatically select an appropriate C++ standard based on task requirements and configure the corresponding compilation options in CMakeLists.txt (such as CMAKE_CXX_STANDARD). The default preference is C++17 or C++20 to take advantage of the best language features.
How do I use cpp-pro for C++ code refactoring?
Provide the C++ code snippet that needs refactoring and describe the refactoring goals (for example, "replace raw pointers with smart pointers", "use STL algorithms instead of loops", or "upgrade to C++20"). cpp-pro will analyze the code issues, apply modern C++ best practices, and explain the reasons for each change. For complex projects, it's recommended to refactor module by module.
Can cpp-pro generate C++ code with tests?
Yes. Projects generated by cpp-pro include full test framework support, with a choice of Google Test or Catch2 for unit tests. For performance-critical code, Google Benchmark will be generated for benchmarking. All code is validated with AddressSanitizer and ThreadSanitizer to ensure no memory errors or data races.