O'Reilly logo

Beyond the C++ Standard Library: An Introduction to Boost by Björn Karlsson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Library 1. Smart_ptr

How Does the Smart_ptr Library Improve Your Programs?

• Automatic lifetime management of objects with shared_ptr makes shared ownership of resources effective and safe.

• Safe observation of shared resources through weak_ptr avoids dangling pointers.

• Scoped resources using scoped_ptr and scoped_array make the code easier to write and maintain, and helps in writing exception-safe code.

Smart pointers solve the problem of managing the lifetime of resources (typically dynamically allocated objects1). Smart pointers come in different flavors. Most share one key feature—automatic resource management. This feature is manifested in different ways, such as lifetime control over dynamically allocated objects, and acquisition and ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required