Fix referenceToSharedPtr to avoid unnecessary exceptions.
This removes the throw of unnecessarily thrown exceptions of bad_weak_ptr when it is clear that there exists no shared_ptr object to created from.
Edited by Robert K
This removes the throw of unnecessarily thrown exceptions of bad_weak_ptr when it is clear that there exists no shared_ptr object to created from.