← ClaudeAtlas

cpp-memory-raiilisted

C++ resource and value semantics: rule of zero and five, RAII wrappers with custom deleters and std::out_ptr, ownership and parameter-passing tables, a move-semantics checklist, smart-pointer choice, std::expected vs exceptions with safety guarantees, dangling-lifetime pitfalls and std::pmr allocation control. Load when designing C++ classes or APIs, fixing leaks, or reviewing ownership.
rustcircle/c101 · ★ 0 · AI & Automation · score 65
Install: claude install-skill rustcircle/c101
# C++ memory, RAII and value semantics Baseline: C++20 everywhere, C++23 library types where the standard library ships them, C++26 types only behind their feature-test macro. Check availability before writing code against it: | Facility | Std | libstdc++ | libc++ | MSVC STL | Gate macro | |---|---|---|---|---|---| | `std::expected` | 23 | 12 | 16 | 19.33 | `__cpp_lib_expected` | | `std::out_ptr` / `std::inout_ptr` | 23 | 14 | 19 | 19.30 | `__cpp_lib_out_ptr` | | `std::move_only_function` | 23 | 12 | - | 19.32 | `__cpp_lib_move_only_function` | | `std::function_ref`, `std::copyable_function` | 26 | 16 | - | - | `__cpp_lib_function_ref`, `__cpp_lib_copyable_function` | | `std::optional<T&>` | 26 | 16 | 22 | - | `__cpp_lib_optional_ref` | | `std::inplace_vector` | 26 | 16 | - | - | `__cpp_lib_inplace_vector` | | `std::indirect`, `std::polymorphic` | 26 | 16 | - | - | check `<version>` | "-" = no release listed in cppreference's support tables (October 2026); Apple clang 21 with libc++ 22 was checked locally: no `move_only_function`, `function_ref` or `inplace_vector`. Deep material: [iterator invalidation by container](references/iterator-invalidation.md) | [RAII patterns: generic handle, scope guard, aliasing, pmr-aware types, type erasure](references/raii-patterns.md) ## 1. Rule of zero; rule of five only inside tiny RAII wrappers Decision procedure for every class: 1. All members already manage themselves (`std::string`, `std::vector`, smart pointers, handle wrappe