<< All versions

Skill v1.0.1

currentAutomated scan100/100
13eholder/modern-cpp-skills/m12-lifecycle

2 files

──Details
PublishedNovember 3, 2026 at 08:59 PM
Content Hashsha256:4a847f34674c06cd...
Git SHA39e0d7f707b2
Bump Typepatch
Compare with v1.0.0
──Files
Files (1 file, 1.4 KB)
SKILL.md1.4 KBactive
SKILL.md · 42 lines · 1.4 KB

name: m12-lifecycle description: "Mastering C++ Lifecycle: RAII, Destructors, Static Initialization, Rule of 5." metadata: version: "1.0.1"


C++ Resource Lifecycle

Core Question

When does this die?

  • Stack: End of scope }.
  • Heap: When delete (or smart pointer drop) occurs.
  • Static: At program exit (reverse init order).

Error → Design Question

IssueDesign Question
Resource LeakDid you manually open() without a wrapper class?
Use After FreeDid you capture a reference to a local variable in a lambda/thread?
Static FiascoDo statics depend on each other? (Use Meyers Singleton).

Thinking Prompt

  1. Does it have a destructor?
  • Yes → RAII. Good.
  • No → Wrap it.
  1. Does it copy?
  • FILE* cannot copy. Delete copy constructor.

Quick Reference

PatternUse Case
RAII WrapperFileHandle, LockGuard.
Scope Guardstd::scope_exit (Cleanup callback).
Rule of 5Copy/Move/Destructor implementation logic.
← v1.0.0All versions