January 2020
Intermediate to advanced
454 pages
11h 25m
English
In this recipe, we will learn how to work with circular references. A circular reference occurs when we're using more than one std::shared_ptr, where each std::shared_ptr owns a reference to the other. This recipe is important as this type of circular reference can occur when we're working with circularly dependent objects (although this should be avoided whenever possible). If it does occur, the shared nature of std::shared_ptr results in a memory leak. This recipe will provide you with the skills to avoid said memory leak using std::weak_ptr.