This is the last of several posts I wrote related to smart pointers:
In modern C++ applications (C++11 and later), you can replace almost all your naked pointers to shared_ptr
and unique_ptr
in order to have automatic resource administration in a deterministic way so you will not need (almost, again) to release the memory manually.
The “almost” means that there is one scenario where the smart pointers, specifically, the shared_ptr
instances, will not work: When you have circular references. In this scenario, since every shared_ptr is pointing to the other one, the memory will never be released.