Skip to main content

4 docs tagged with "smart-pointers"

View all tags

Custom Deleters

Extend smart pointers to manage any resource requiring special cleanup beyond delete. Enable RAII for files, handles, connections, locks - anything needing cleanup.

std::shared_ptr

Smart pointer with shared ownership via reference counting. Multiple shared_ptrs can own the same object, deleted when last owner destroyed.

std::unique_ptr

Smart pointer with exclusive ownership. Zero overhead, automatic cleanup, move-only semantics. The default choice for dynamic memory.

std::weak_ptr

Non-owning observer of shared_ptr-managed objects. Doesn't increase reference count, enables checking if object still exists.