[#absl-WeakenPtr] = xref:absl.adoc[absl]::WeakenPtr :relfileprefix: ../ :mrdocs: Create a weak pointer from a shared pointer. == Synopsis Declared in `<absl/memory/memory.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<typename T> std::weak_ptr<T> WeakenPtr(std::shared_ptr<T> const& ptr); ---- == Description Creates a weak pointer associated with a given shared pointer. The returned value is a `std::weak_ptr` of deduced type. Example: auto sp = std::make_shared<int>(10); auto wp = absl::WeakenPtr(sp); CHECK_EQ(sp.get(), wp.lock().get()); sp.reset(); CHECK(wp.lock() == nullptr); == Return Value A `std::weak_ptr` referring to the value owned by `ptr`. == Parameters [cols="1,4"] |=== | Name| Description | *ptr* | The shared pointer to observe. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#