Here are the things I know about smart pointers
- shared_ptr is a smart pointer such that multiple shared_ptr can point to an object in the heap. Even if one of the shared_ptr is deleted the object in the heap will not be destroyed as long as it's reference count is above zero.
- a weak_ptr also points to an object in the heap but it does not increases the reference count of that object
- we can use weak_ptr to break circular reference
In the case of Doubly Linked Lists we have two pointers to point to the previous and the next node. We use a shared_ptr and a weak_ptr in the implementation. Why don't we use two weak_ptr ?