sutter_skill
- Python
3
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill copyleftdev/sk1llz --skill sutter- SKILL.md5.8 KB
Overview
This skill encodes Herb Sutter’s Exceptional C++ principles into practical C++ guidance and patterns. It helps you write robust, exception-safe, const-correct, and maintainable C++ suitable for production systems. Use it to enforce clear guarantees, RAII-based resource management, and modern idioms that reduce bugs and simplify reasoning about code.
How this skill works
The skill inspects design choices and suggests patterns that ensure one of the standard exception-safety guarantees (no-throw, strong, basic). It recommends concrete code idioms: noexcept destructors and move ops, copy-and-swap assignments, RAII, smart pointers, std::optional/std::variant, and const-correct APIs. It also flags risky practices (throwing in destructors, raw owning pointers, missing noexcept) and offers safer replacements.
When to use it
- When designing APIs that must document and enforce exception-safety guarantees
- When writing classes that manage resources and need RAII and move/copy correctness
- When converting legacy code to modern C++ idioms (smart pointers, std::optional, std::variant)
- When you need clear const-correct interfaces and logical-const patterns
- When preparing code for high-reliability production or library use
Best practices
- Always state the exception-safety guarantee for functions and classes
- Make destructors, swap, and move operations noexcept where possible
- Prefer value semantics and smart pointers over raw owning pointers
- Use copy-and-swap for strong exception-safe assignment and RAII for all resources
- Use const member functions and mutable only for true logical constness
- Prefer algorithms, std::optional/std::variant, and make_unique/make_shared
Example use cases
- Implementing a thread-safe API that returns copies or const refs while preserving logical const
- Refactoring a resource-managing class to RAII with noexcept move operations and copy-and-swap assignment
- Designing a library that exposes strong guarantees: no leaks, consistent state after exceptions
- Building a Pimpl-based type with explicit out-of-line special member definitions to hide implementation and preserve noexcept moves
- Replacing raw pointer ownership and null-return patterns with smart pointers and std::optional
FAQ
Aim for the basic guarantee for most functions and strong guarantee for operations that modify container-like state; reserve no-throw for destructors, swap, and move where feasible.
When is it acceptable to use mutable for const member functions?
Use mutable only to protect synchronization primitives or cached data that do not affect the object’s observable logical state; document the intent clearly.
Should I always mark move operations noexcept?
Mark move operations noexcept when possible; it enables optimal container moves and stronger exception-safety reasoning. If a move can throw, provide a safe fallback and document the behavior.