Goal: safe, modern C++ that manages resources automatically.
Use for:
- new C++ code or modernizing raw-pointer code
- reviewing memory management, ownership, and safety
- replacing new/delete and manual resource handling
Workflow:
- Manage resources with RAII; tie lifetime to scope.
- Use smart pointers (unique_ptr, shared_ptr) over raw owning pointers.
- Prefer value semantics and move where copies are costly.
- Use the standard library containers and algorithms.
- Mark const correctness and noexcept where applicable.
- Verify with tests, sanitizers (ASan/UBSan), and warnings-as-errors.
Idioms:
- rule of zero; let RAII types manage resources
- unique_ptr for single ownership, shared_ptr only when shared
- std::move to transfer, not to micro-optimize blindly
- range-based loops and algorithms over index loops
Rules:
- no naked new/delete in application code
- pass by const reference for non-trivial reads
- run with sanitizers to catch UB and leaks
- prefer the standard library before hand-rolling