MENU

Fun & Interesting

Back to Basics: RAII and the Rule of Zero - Arthur O'Dwyer - CppCon 2019

CppCon 81,659 5 years ago
Video Not Working? Fix It Now

http://CppCon.org — Discussion & Comments: https://www.reddit.com/r/cpp/ — Presentation Slides, PDFs, Source Code and other presenter materials are available at: https://github.com/CppCon/CppCon2019 — RAII, or "Resource Allocation is Initialization," is one of the cornerstones of C++. What is it, why is it important, and how do we use it in our own code? Small resource-managing classes should follow the Rule of Three (or Five); larger, composite, business-logic classes should follow the Rule of Zero. We'll explain these "Rules," what they mean, and how their consistent application helps us avoid resource leaks and double-frees. We'll also show how thinking about the Rule of Three can lead to a consistent guideline for polymorphic classes with virtual destructors. Finally, we'll touch on the "copy and swap" idiom, which in many cases can reduce the Rule of Five to the Rule of Four (and a Half). Attendees will leave this session with a clearer understanding of resource management in C++. — Arthur O'Dwyer New York Arthur O'Dwyer is the author of "Colossal Cave: The Board Game," "Mastering the C++17 STL" (the book), and "The STL From Scratch" (the training course). He runs professional C++ training courses, is occasionally active on the C++ Standards Committee, and has a blog mostly about C++. — Videos Filmed & Edited by Bash Films: http://www.BashFilms.com *-----* Register Now For CppCon 2022: https://cppcon.org/registration/ *-----*

Comment