Smart pointer
A smart pointer is a pointer-like object that manages or mediates access to a referenced resource, often providing ownership, lifetime, or safety behavior.
100 C++ Mistakes and How to Avoid Them
A smart pointer is a C++ pointer-like object that manages the lifetime of a dynamically allocated resource according to an ownership policy.
- How it is used
- Manages dynamically allocated resources through ownership policies, especially across normal scope exit and exceptions.
- How deep it goes
- Explains RAII, exclusive ownership, reference counting, transfer, and cycles, while deferring detailed implementation mechanics.
- Examples
- Uses Student allocation, file-reading classes, and a deque to contrast raw, exclusive, and shared resource management.
- What you can do after
- Apply it via C++ or Boost pointer types, selecting exclusive or shared ownership and avoiding manual cleanup.
Read how 100 C++ Mistakes and How to Avoid Them explains smart pointer →
Idiomatic Rust
A smart pointer is a pointer-like value that manages or mediates access to the data it references.
- How it is used
- Selects allocation or shared-ownership behavior and enables storage of unsized trait objects in Rust.
- How deep it goes
- Explains pointer selection and allocation tradeoffs with Rust examples, but does not detail reference-counting internals.
- Examples
- Compares `Vec<Box<String>>` with `Vec<String>` and stores two concrete types in a `Vec<Box<dyn MyTrait>>`.
- What you can do after
- Evaluate/understand when to use `Box`, `Rc`, or `Arc` and when extra smart pointers signal needless allocation or avoided borrowing.
Learn C++ by Example
A smart pointer is a C++ library type that manages an object pointer and can automate ownership and storage cleanup.
- How it is used
- Uses smart pointers to manage polymorphic blob objects stored together in a vector.
- How deep it goes
- Explains the cleanup problem and polymorphic role, but does not distinguish smart-pointer varieties or detail ownership semantics.
- Examples
- Uses a race containing stepper and randomly moving Blob objects as the central example.
- What you can do after
- Apply smart pointers to store varied derived objects safely in a polymorphic collection.
Rust in Action: Systems programming concepts and techniques
A smart pointer is a pointer-like data structure that provides additional capabilities such as ownership management, reference counting, or synchronization.
- How it is used
- Positions smart pointers as safer, feature-rich alternatives to raw pointers when working with Rust memory.
- How deep it goes
- Defines smart pointers, compares their capabilities, and names construction primitives, but defers a full account of building safe pointer types.
- Examples
- Compares the addresses and sizes of a reference and Box<[u8]>, and combines Rc<T> with RefCell<T>.
- What you can do after
- Evaluate/understand which named Rust pointer types offer shared access, interior mutability, or weak access, and what costs added features bring.
Read how Rust in Action: Systems programming concepts and techniques explains smart pointer →
Learn Rust in a Month of Lunches
A smart pointer is a pointer-like data structure that manages an owned or referenced value and provides behavior beyond raw address storage.
- How it is used
- Explains pointer-like wrappers through ownership, recursive structures, trait objects, and custom dereferencing.
- How deep it goes
- Defines smart pointers and works through Box and Deref, but does not develop Rc or RefCell behavior in detail.
- Examples
- Uses Box<i32>, recursive Holder values, compiler diagnostics, Box<dyn Error>, and a custom HoldsANumber wrapper.
- What you can do after
- Apply it via Box and Deref to build recursive values, access boxed data, and design pointer-like wrappers.
Read how Learn Rust in a Month of Lunches explains smart pointer →
Related concepts
- Boxincludes · Box is a Rust owning smart pointer that provides indirection by storing a uniquely owned value in heap-allocated memory.
- Arcincludes · Arc is Rust’s atomically reference-counted smart pointer for shared ownership of a value across threads.
- Rcincludes · Rc is Rust’s single-threaded reference-counted smart pointer for shared ownership of a value.
- referencekind of · A reference is an indirect value or relationship that identifies or provides access to another value, object, resource, or source.
- refcellincludes · RefCell is a Rust standard-library container that provides interior mutability by checking borrowing rules at runtime.
- auto_ptrincludes · std::auto_ptr was a legacy C++ standard-library smart pointer with ownership-transferring copy semantics, deprecated in C++11 and removed in C++17.
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.




