The Smart Pointers I Wish I Had - Matthew Fleming - CppCon 2019

Опубликовано: 10 Май 2025
на канале: CppCon
12,739
208

http://CppCon.org
Discussion & Comments:   / cpp  
Presentation Slides, PDFs, Source Code and other presenter materials are available at: https://github.com/CppCon/CppCon2019

The Smart Pointers I Wish I Had

C++ offers two owning smart pointers, and a proposed non-owning smart pointer in the C++20 Library Fundamentals v2 Technical Specification. This talk will cover the kinds of semantics I think are important in a non-owning pointer, why I think more than one is desirable, and why the existing C++ owning smart pointers are sub-optimal for some use-cases. I will show how correct use of non-owning smart pointers can reduce memory lifetime issues, clarify code, and nearly eliminate incorrect ownership.

For asynchronous programming especially, the lifetime of observing pointers can be a source of significant and difficult to debug issues. I'll cover a mental model to use when writing code that helps focus on where lifetime issues might be likely, and where they will be unlikely.

Matthew Fleming

I've been working in systems software for almost 20 years now, mostly on virtual memory and filesystems, in both C and C++. I tend to find myself gravitating lower and lower in the stack, to code primitives, library helpers, and getting very close to the hardware.


Videos Filmed & Edited by Bash Films: http://www.BashFilms.com

*-----*
Register Now For CppCon 2022: https://cppcon.org/registration/
*-----*