Standard resource management automation tools
The standard library offers a significant number of classes that manage memory efficiently. One needs only consider the standard containers to see shining examples of the sort. In this section, we will take a quick look at a few examples of types useful for resource management. Far from providing an exhaustive list, we’ll try to show different ways to benefit from the RAII idiom.
As mentioned before, when expressing a type that provides automated resource management, the key aspects of that type’s behavior are expressed through its six special member functions. For that reason, with each of the following types, we will take a brief look at what the semantics of these functions are.
unique_ptr<T> and shared_ptr<T>
This short section aims to provide a brief overview of the two main standard smart pointers types in the C++ standard library: std::unique_ptr<T> and std::shared_ptr<T>. It is meant...