You do not convert weak_ptrto shared_ptr, as this may lead to the full purpose of use weak_ptr.
To get shared_ptrfrom instance a weak_ptr, call lockon weak_ptr.
Usually you do the following:
weak_ptr<foo> wp = ...;
if (shared_ptr<foo> sp = wp.lock())
{
}
source
share