Loading…
CppCon 2019 has ended
Tuesday, September 17 • 09:00 - 10:00
Back to Basics: RAII and the Rule of Zero

Log in to save this to your schedule and see who's attending!

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++.

Speakers
avatar for Arthur O'Dwyer

Arthur O'Dwyer

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... Read More →


Tuesday September 17, 2019 09:00 - 10:00
Aurora A

Attendees (308)




Twitter Feed