[#bsl-weak_ptr-0d-lock]
= xref:bsl.adoc[bsl]::xref:bsl/weak_ptr-0d.adoc[weak&lowbar;ptr]::lock
:relfileprefix: ../../
:mrdocs:

Return a shared pointer to the object referred to by this weak pointer if `false &equals;&equals; expired()`, and a shared pointer in the empty state otherwise&period;

== Synopsis

Declared in `&lt;bslstl&lowbar;sharedptr&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:bsl/shared_ptr-0a.adoc[shared&lowbar;ptr&lt;ELEMENT&lowbar;TYPE&gt;]
lock() const noexcept;
----

== Return Value

shared pointer to the observed object, or empty if expired


[.small]#Created with https://www.mrdocs.com[MrDocs]#
