This is my learning notes from the course - Mastering C++ Standard Library Features.
Shared Pointers and Weak Pointers
- the concept of shared ownership
- What
std::shared_ptr
andstd::make_shared
are - What
std:: weak_ptr
is - Run-time overhead
Shared Ownership
The reasons of using shared ownership:
- Some resources need to be shared between multiple owners
- After acquisition of a resource, multiple objects can take/lose ownership of it
- When a resource has no more owners, it is automatically release
- Useful where there isn’t a clear lifetime for a particular resource (for example might depend on run-time conditions)