cpp-native-development

Apply modern C++17/20 patterns for move semantics, templates, and thread safety.

2|Updated May 15, 2015
One-click install
npx skills add https://github.com/stephendolan/dotfiles --skill cpp-native-development
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cpp-native-development
Source: https://github.com/stephendolan/dotfiles/tree/main/claude/skills/cpp-native-development
Command: npx skills add https://github.com/stephendolan/dotfiles --skill cpp-native-development

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill guides writing performant, modern C++ with emphasis on move semantics, templates, thread safety, and API design.

Core Features & Use Cases

  • Move Semantics & Layout: Prefer rvalue references and explicit moves to avoid copies.
  • Templates vs std::function: Use templates for zero-cost abstractions; reserve std::function for non-hot paths.
  • Lifetime & Thread Safety: Proper ownership, safe destructors, and locking discipline.
  • Initialization & API Design: Initialize structs, design clean APIs, and avoid undefined states.

Quick Start

Explain the difference between move semantics and copying in a function that takes a vector by value.

Frequently Asked Questions about cpp-native-development

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I use move semantics to avoid unnecessary copying in C++?

Move semantics lets you transfer ownership of resources instead of copying them. Use rvalue references (&&) and std::move to enable efficient transfers, reducing allocations and improving performance in functions that accept vectors, strings, or other heavy objects by value.

When should I use templates instead of std::function?

Templates provide zero-cost abstractions with compile-time polymorphism and no runtime overhead, making them ideal for performance-critical code paths. Reserve std::function for callbacks in non-hot paths where the indirection cost is acceptable and runtime flexibility is needed.

What's the best way to ensure thread safety in modern C++?

Thread safety requires proper ownership discipline, explicit locking patterns, and safe destructors. Use RAII for lock guards, avoid data races through synchronization primitives, and design APIs that prevent shared mutable state where possible.

How do I design APIs that avoid undefined initialization states?

Enforce explicit struct initialization by requiring constructors with all mandatory fields, use default member initializers for safety, and design APIs that prevent partially constructed or invalid states through type-safe interfaces.

Can I apply modern C++ patterns when maintaining C++17 codebases?

Modern C++ patterns like move semantics, template metaprogramming, and explicit lifetime management are fully available in C++17 and later. These practices improve performance and safety across existing codebases through API redesign and initialization refactoring.