If I call std::make_shared
(rather than just allocating a shared_ptr
explicitly) then I expect the reference count to be allocated in
The common implementation is for the ref control block of an std::shared_ptr
to contain both a strong and a weak reference count separately. The managed object is destroyed when the strong reference count goes to zero, but the ref control block itself is only released when the weak reference count also reaches zero.
(When you use std::make_shared
, the ref control block itself contains enough memory to hold the managed object. This is just a detail.)
In other words, the observable behaviour for the managed object is independent of weak pointers.