Documentation Home >> Headers >> <jss/experimental_atomic.hpp> Header >> std::experimental::weak_ptr >> std::experimental::lock member function

Create a std::experimental::shared_ptr object that shares ownership with *this.

shared_ptr<T> lock() const noexcept;

Returns:

If this->expired() is true, a default-constructed std::experimental::shared_ptr object, otherwise a std::experimental::shared_ptr that holds the value held by *this and shares ownership with *this.

Postconditions:

If this->expired(), result.get()==nullptr and result.use_count()==0. Otherwise, result.get() returns the stored pointer held in *this. If this->use_count() is non zero it is increased by 1 and result.use_count()>1.

Throws:

Nothing.

Header

#include <experimental/atomic>

See Also