filmov
tv
CppCon 2018: Peter Sommerlad “Woes of Scope Guards and Unique_Resource - 5+ years in the making”
Показать описание
—
—
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.
—
Peter Sommerlad, HSR Rapperswil
Professor
Prof. Peter Sommerlad is director of IFS Institute for Software at FHO HSR Rapperswil where he inspired the C++ IDE Cevelop. Peter is co-author of the books POSA Vol.1 and Security Patterns. His goal is to make software simpler by Decremental Development: Refactoring software down to 10% its size with better architecture, testability and quality and functionality. Peter is a member of the C++ standardization committee, ACCU, ACM, IEEE Computer Society.
—
*-----*
*-----*
—
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.
—
Peter Sommerlad, HSR Rapperswil
Professor
Prof. Peter Sommerlad is director of IFS Institute for Software at FHO HSR Rapperswil where he inspired the C++ IDE Cevelop. Peter is co-author of the books POSA Vol.1 and Security Patterns. His goal is to make software simpler by Decremental Development: Refactoring software down to 10% its size with better architecture, testability and quality and functionality. Peter is a member of the C++ standardization committee, ACCU, ACM, IEEE Computer Society.
—
*-----*
*-----*