Implementation of lock()

Viewed 176

According to boost:

To access the object, a weak_ptr can be converted to a shared_ptr using the shared_ptr constructor or the member function lock.

Again, from boost:

shared_ptr<T> lock() const;

//Returns: expired()? shared_ptr<T>(): shared_ptr<T>(*this).

As far as I understand, returning shared_ptr<T>(*this) means creating a new shared_ptr with reference count of 1; And this is definitely not what we want. So probably I'm not understand it right. Will someone explain? Thanks!

1 Answers
Related