liveBook · Manning

Std::shared_ptr

std::shared_ptr is a C++ standard-library smart pointer that enables multiple owners to share ownership of a dynamically allocated object.

How 2 Manning books explain it

100 C++ Mistakes and How to Avoid Them

std::shared_ptr is a C++ standard-library smart pointer that maintains shared ownership of a dynamically allocated object through reference counting.

How it is used
Manages dynamically allocated resources when multiple references share one entity.
How deep it goes
Explains RAII-based shared ownership through deque member changes and deletion risks, without detailing pointer internals.
Examples
Uses a double-ended queue whose nodes link through shared_ptr, alongside raw-pointer and legacy smart-pointer resource examples.
What you can do after
Apply it via std::make_shared to replace raw-pointer ownership in shared-resource structures and reduce deletion code.

Read how 100 C++ Mistakes and How to Avoid Them explains std::shared_ptr →

C++ Concurrency in Action, Second Edition

`std::shared_ptr` is a C++ standard library smart pointer that shares ownership of a dynamically allocated object.

How it is used
Returns stack values safely from pop() without allocating during the removal operation.
How deep it goes
Demonstrates shared_ptr in a lock-free stack, but leaves node reclamation unresolved.
Examples
Uses a lock-free stack whose push allocates shared data and whose pop returns a pointer or an empty value.
What you can do after
Apply std::shared_ptr to return stack data without a throwing allocation during pop().

Read how C++ Concurrency in Action, Second Edition explains std::shared_ptr →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.