[#bsl-weak_ptr-0d] = xref:bsl.adoc[bsl]::weak_ptr :relfileprefix: ../ :mrdocs: This `friend` declaration provides access to the internal data members while constructing a weak pointer from a weak pointer of a different type. == Synopsis Declared in `<bslstl_sharedptr.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class ELEMENT_TYPE> class weak_ptr; ---- == Type Aliases [cols="1,4"] |=== | Name| Description | xref:bsl/weak_ptr-0d/element_type.adoc[`element_type`] | Alias to the element type referenced by this `weak_ptr`. |=== == Member Functions [cols="1,4"] |=== | Name| Description | xref:bsl/weak_ptr-0d/2constructor-03.adoc[`weak_ptr`] [.small]#[constructor]# | Constructors | xref:bsl/weak_ptr-0d/2destructor.adoc[`~weak_ptr`] [.small]#[destructor]# | Destroy this weak pointer object. If this weak pointer manages a (possibly shared) object, release the weak reference to that object. | xref:bsl/weak_ptr-0d/operator_assign-09.adoc[`operator=`] | Assignment operators | xref:bsl/weak_ptr-0d/acquireSharedPtr.adoc[`acquireSharedPtr`] | Return a `shared_ptr` to the observed object, or empty if expired. | xref:bsl/weak_ptr-0d/expired.adoc[`expired`] | Return `true` if this weak pointer is in the empty state or the object that it originally referenced has been destroyed, and `false` otherwise. | xref:bsl/weak_ptr-0d/lock.adoc[`lock`] | Return a shared pointer to the object referred to by this weak pointer if `false == expired()`, and a shared pointer in the empty state otherwise. | xref:bsl/weak_ptr-0d/numReferences.adoc[`numReferences`] | Return the number of `shared_ptr` owners of the observed object. | xref:bsl/weak_ptr-0d/owner_before-00.adoc[`owner_before`] | Return whether this `weak_ptr` precedes `other` in owner order. | xref:bsl/weak_ptr-0d/owner_equal-02.adoc[`owner_equal`] | Return whether this pointer shares ownership with `other`. | xref:bsl/weak_ptr-0d/owner_hash.adoc[`owner_hash`] | Return a hash value based on this pointer's ownership identity. | xref:bsl/weak_ptr-0d/rep.adoc[`rep`] | Return the address of the held representation, or null if empty. | xref:bsl/weak_ptr-0d/reset.adoc[`reset`] | Reset this `weak_ptr` to the empty state. | xref:bsl/weak_ptr-0d/swap.adoc[`swap`] | Exchange the state of this `weak_ptr` with `other`. | xref:bsl/weak_ptr-0d/use_count.adoc[`use_count`] | Return the number of `shared_ptr` owners of the observed object. | xref:bsl/weak_ptr-0d/2conversion.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration<weak_ptr<ELEMENT_TYPE>, is_nothrow_move_constructible>`] | Nested trait declaration for `is_nothrow_move_constructible`. |=== == Deduction Guides [cols="1,4"] |=== | Name| Description | xref:bsl/weak_ptr-07.adoc[`weak_ptr<ELEMENT_TYPE>`] | Deduce the specified type `ELEMENT_TYPE` corresponding template parameter of the `bsl::shared_ptr` supplied to the constructor of `weak_ptr`. |=== == Friends [cols="1,4"] |=== | Name| Description | `bsl::weak_ptr` | This `friend` declaration provides access to the internal data members while constructing a weak pointer from a weak pointer of a different type. |=== == Non-Member Functions [cols="1,4"] |=== | Name| Description | xref:bsl/swap-0447.adoc[`swap`] | Exchange the states of the specified `weak_ptr` objects `a` and `b`. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#