-
Book Overview & Buying
-
Table Of Contents
C++ Memory Management
By :
Our last topic for this chapter on new approaches to memory management and optimization opportunities that pertain to object lifetime is type-aware allocation and deallocation functions. This is a novel approach to allocation functions for cases where user code might want to somehow use information with respect to what type is undergoing allocation (and eventual construction) to guide the allocation process.
We saw one facet of such features in Chapter 9 when describing the destroying delete mechanism made possible by C++20, where a member-function version of T::operator delete() is passed T* instead of the abstract void* as an argument, and is for that reason made responsible for both the finalization of the object and the deallocation of its underlying storage. We saw that there are cases where this reveals interesting optimization opportunities.
What is under discussion for C++26 is a new family of operator new() and operator...