[shared_from_this] why doesn't _internal_weak_this need to be initialized?

In the shared_from_this() function of the enable_shared_from_this base class, the weak pointer _internal_weak_this is never initialized. Why is that so? The use_count of the _internal_weak_ptr is at least 1 as long as there is a shared_ptr already pointing to *this. How does the un-initialized weak_ptr know that there is a shared_ptr already created and how can it access the number of references? I'm sure there is a simple explanation that I am not catching in my readings. thanks jose "survival first, then happiness as we can manage it"

On Sunday 18 May 2008 00:10, Jose Martinez wrote:
In the shared_from_this() function of the enable_shared_from_this base class, the weak pointer _internal_weak_this is never initialized. Why is that so? The use_count of the _internal_weak_ptr is at least 1 as long as there is a shared_ptr already pointing to *this. How does the un-initialized weak_ptr know that there is a shared_ptr already created and how can it access the number of references? I'm sure there is a simple explanation that I am not catching in my readings.
It gets initialized by the shared_ptr constructor. -- Frank
participants (2)
-
Frank Mori Hess
-
Jose Martinez