Writing Generic Containers with Explicit Memory Management
We have come quite a long way since the beginning of our journey into the wonders of memory management mechanisms and techniques in C++. From Chapter 4 to Chapter 7, we built an interesting toolbox, one on which we can build and from which we can adapt to solve new problems we might face in the future. This toolbox now contains, among other things, the following:
- Techniques through which an object implicitly manages its resources
- Types that behave like pointers but encode responsibility over the pointee in the type system
- Various ways in which we can take over the behavior of memory allocation mechanisms of a program
One (important!) aspect of memory management we have not covered yet is how containers manage memory. This is actually quite an interesting topic, one that we will address through three different angles, in three different chapters.
The first angle is how to handle memory management explicitly...