Smart pointers

A smart pointer, definitively, is a class that encapsulates access to a pointer and often manages memory associated with the pointer. If you paid attention, you would have noticed the similarity smart pointers have with pineapples—smart pointers are classes, not pointers, just as pineapples aren't really apples. Moving away from fruit analogies, different types of smart pointers often have additional features like bounds-checking, null-checking, and access control, among others. In C++, smart pointers usually overload the dereference operator (operator->), which allows any method calls invoked on the smart pointer using operator-> to be bound to the underlying pointer.

Boost includes a set of four different smart pointers with differing ...

Get Learning Boost C++ Libraries now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.