In c++0x, there is a std::static_pointer_cast for std::shared_ptr, but there is no equivalent method for std::weak_ptr. Is this intentional, or an oversight? If an oversight, how would I define an appropriate function?
In c++0x, there is a std::static_pointer_cast for std::shared_ptr, but there is no equivalent method
Share
This ought to do it for you:
This will throw an exception if the weak_ptr has expired. If you would rather get a null weak_ptr, then use
r.lock()instead.