Why does control block in shared_ptr maintain weak reference counter??

ref: StackOverflow"s question address

The

answer explained that weak reference counters have an impact on the life cycle of control block. I understand that new is different from make_shared, but I don"t understand why control block needs to maintain weak reference counters. Without maintenance, you can not bind to the control block lifecycle or even the entire object lifecycle in make_shared?

Mar.15,2021

the object will be destructed when the strong reference count (uses) is 0, and the ref counter object will be deleted when the weak reference count (weaks) is 0, so there will be a uses and a weaks

when the shared_ptr is created.
Menu