Loading…
CppCon 2018 has ended
Tuesday, September 25 • 14:00 - 15:00
Woes of Scope Guards and Unique Resource - 5+ years in the making

Sign up or log in to save this to your schedule, view media, leave feedback and see who's attending!

C++ major benefit is its deterministic lifetime model of variables and values. This lead to the RAII (resource-acquisition is initialization) idiom that is essential for resource safety and less leakage. Some standard library classes already implement RAII for specific cases, such as heap-allocated pointers, mutex locking or file-I/O.

While some "mis"-uses of unique_ptr are recommended as a general RAII wrapper, those uses sometimes fail to be general enough. This lead Andrew Sandoval to specify a unique resource wrapper for the standard libary in 2013 (N3677). This talk tells the story how the author helped shepherding that mechanism through at least 12 revisions to make it into the standard library, which might be achieved while CPPCon runs, or not yet (hopes are high).

Implementing a RAII wrapper seems trivial, just implement a constructor and destructor, but doing so in generic ways is hard and tricky. Even with simple DIY solutions, interesting effects lurk and can lead to surprises also when using the generic solutions potentially provided by C++20.


Speakers
avatar for Peter Sommerlad

Peter Sommerlad

founder, Better Software: Consulting, Training, Reviews
Peter Sommerlad was director of IFS Institute for Software at FHO/HSR Rapperswil, Switzerland. Peter is co-author of the books POSA Vol.1 and Security Patterns and contributed to "97 things every programmer should know". His goal is to make software simpler and safer by Decremental... Read More →


Tuesday September 25, 2018 14:00 - 15:00 PDT
Winter Park (406)
  • Object Model