cpp

Smart Pointers (REQUIRED)

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "cpp" with this command: npx skills add poletron/custom-rules/poletron-custom-rules-cpp

Critical Patterns

Smart Pointers (REQUIRED)

// ✅ ALWAYS: Use smart pointers auto user = std::make_unique<User>("John"); auto shared = std::make_shared<Config>();

// ❌ NEVER: Raw new/delete User* user = new User("John"); delete user;

RAII (REQUIRED)

// ✅ ALWAYS: Resource management through constructors/destructors class FileHandle { std::fstream file_; public: FileHandle(const std::string& path) : file_(path) {} ~FileHandle() { if (file_.is_open()) file_.close(); } };

Modern Patterns (REQUIRED)

// ✅ Use auto for type deduction auto items = std::vector<int>{1, 2, 3};

// ✅ Use range-based for loops for (const auto& item : items) { process(item); }

// ✅ Use structured bindings auto [name, age] = getPerson();

Decision Tree

Need unique ownership? → std::unique_ptr Need shared ownership? → std::shared_ptr Need optional value? → std::optional Need multiple types? → std::variant Need string views? → std::string_view

Commands

g++ -std=c++20 -Wall -Wextra main.cpp -o app clang++ -std=c++20 main.cpp -o app cmake -B build && cmake --build build

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

lancedb

No summary provided by upstream source.

Repository SourceNeeds Review
General

coding-standards

No summary provided by upstream source.

Repository SourceNeeds Review
General

javascript-mastery

No summary provided by upstream source.

Repository SourceNeeds Review