AI Skill Report Card
Generated Skill
Modern C++ Development
Quick Start
C++// CMakeLists.txt cmake_minimum_required(VERSION 3.20) project(MyProject VERSION 1.0.0 LANGUAGES CXX) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) add_executable(${PROJECT_NAME} src/main.cpp) target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -O2) // src/main.cpp #include <iostream> #include <vector> #include <ranges> #include <algorithm> int main() { std::vector<int> data{1, 2, 3, 4, 5}; auto result = data | std::views::filter([](int x) { return x % 2 == 0; }) | std::views::transform([](int x) { return x * x; }); for (auto value : result) { std::cout << value << " "; } return 0; }
Recommendation▾
Consider adding more specific examples
Workflow
-
Project Setup
- Create CMakeLists.txt with C++20/23 standard
- Set compiler warnings and optimization flags
- Define clear directory structure (src/, include/, tests/)
-
Code Development
- Use modern C++ features: auto, range-based loops, smart pointers
- Leverage STL algorithms and containers
- Apply RAII principles consistently
- Use constexpr for compile-time computation
-
Build Configuration
- Configure release/debug builds
- Set up unit testing with CMake
- Add static analysis targets
Progress:
- CMake project structure created
- Core functionality implemented with modern C++
- Build configurations tested
- Code reviewed for standard compliance
Recommendation▾
Include edge cases
Examples
Example 1: String Processing Input: Parse CSV data efficiently Output:
C++#include <string_view> #include <vector> #include <ranges> auto parse_csv(std::string_view data) { return data | std::views::split(',') | std::views::transform([](auto&& range) { return std::string{range.begin(), range.end()}; }) | std::ranges::to<std::vector>(); }
Example 2: Resource Management Input: File handling with automatic cleanup Output:
C++#include <fstream> #include <memory> class FileHandler { std::unique_ptr<std::ifstream> file_; public: explicit FileHandler(const std::string& path) : file_(std::make_unique<std::ifstream>(path)) {} auto read_lines() const -> std::vector<std::string> { std::vector<std::string> lines; std::string line; while (std::getline(*file_, line)) { lines.push_back(std::move(line)); } return lines; } };
Best Practices
- Always use the latest stable C++ standard (C++20/23)
- Prefer stack allocation over heap when possible
- Use
constexprandconstevalfor compile-time computation - Apply
constcorrectness throughout - Leverage move semantics for performance
- Use structured bindings for cleaner code
- Employ concepts for template constraints (C++20)
- Keep CMake scripts simple and focused
Common Pitfalls
- Don't use raw pointers for ownership
- Avoid C-style casts, use static_cast/dynamic_cast
- Don't ignore compiler warnings
- Avoid deep inheritance hierarchies
- Don't use
using namespace stdin headers - Avoid manual memory management when STL containers suffice
- Don't over-engineer with unnecessary template metaprogramming