Summary
This chapter formalized the requirements for exception safety of a piece of code, and then defined various means of managing dynamically-allocated objects in an exception-safe way using smart pointers. We looked at smart pointer templates both from Boost and ones that have been introduced by the new C++11 Standard, and understood the different ownership semantics and intrusive and nonintrusive reference counting. We also got a chance to look at ways of adapting some of the smart pointer templates for managing non-memory resources.
Hopefully, you have understood the various ownership semantics and would be able to judiciously apply the techniques in this chapter to such scenarios. There are facilities in the smart pointer library that we ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access