Back to Basics: Smart Pointers (Arthur O'Dwyer)
Details
Smart pointers are one of the key features of modern C++. We'll cover the two fundamental strategies used by the standard smart pointers: unique ownership transfer and reference-counting. We'll show how shared_ptr uses control blocks to implement reference-counting of arbitrary objects, and how to use weak_ptr in conjunction with shared_ptr. We'll explain the convenience functions make_shared and make_unique, and demonstrate how they are more than just conveniences. Finally, we'll motivate, implement, and demystify the curiously recurring template enable_shared_from_this.
Attendees will leave with a clear understanding of how C++11's smart pointers work under the hood.
Arthur O'Dwyer offers professional C++ training courses, is occasionally active on the C++ Standards Committee, and has a blog mostly about C++. He chaired the "Back to Basics" track at CppCon 2019, where he gave this talk for the first time.