[#absl-WeakenPtr]
= xref:absl.adoc[absl]::WeakenPtr
:relfileprefix: ../
:mrdocs:

Create a weak pointer from a shared pointer&period;

== Synopsis

Declared in `&lt;absl&sol;memory&sol;memory&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;typename T&gt;
std::weak&lowbar;ptr&lt;T&gt;
WeakenPtr(std::shared&lowbar;ptr&lt;T&gt; const& ptr);
----

== Description

Creates a weak pointer associated with a given shared pointer&period; The returned value is a `std&colon;&colon;weak&lowbar;ptr` of deduced type&period;

Example&colon;

auto sp &equals; std&colon;&colon;make&lowbar;shared&lt;int&gt;(10)&semi; auto wp &equals; absl&colon;&colon;WeakenPtr(sp)&semi; CHECK&lowbar;EQ(sp&period;get(), wp&period;lock()&period;get())&semi; sp&period;reset()&semi; CHECK(wp&period;lock() &equals;&equals; nullptr)&semi;

== Return Value

A `std&colon;&colon;weak&lowbar;ptr` referring to the value owned by `ptr`&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *ptr*
| The shared pointer to observe&period;
|===


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