[#BloombergLP-bslma-ManagedPtr-0fa-2constructor-0524] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslma.adoc[bslma]::xref:BloombergLP/bslma/ManagedPtr-0fa.adoc[ManagedPtr]::ManagedPtr :relfileprefix: ../../../ :mrdocs: Create an aliasing managed pointer from `alias` targeting `ptr`. == Synopsis Declared in `<bslma_managedptr.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class ALIASED_TYPE> ManagedPtr( xref:BloombergLP/bslma/ManagedPtr-0fa.adoc[ManagedPtr<ALIASED_TYPE>]& alias, TARGET_TYPE* ptr); ---- == Description Create a managed pointer that takes ownership of the object managed by the specified `alias`, but which uses the specified `ptr` to refer to its target object, unless `0 == ptr`, in which case create an empty managed pointer. Reset `alias` to empty if ownership of its managed object is transferred. The behavior is undefined if `alias` is empty, but `0 != ptr`. Note that destroying or re‐assigning a managed pointer created with this constructor will destroy the object originally managed by `alias` (unless `release` is called first); the destructor for `*ptr` is not called directly. == Parameters [cols="1,4"] |=== | Name| Description | *alias* | managed pointer supplying ownership of the managed object | *ptr* | pointer used as the target of this managed pointer, or null |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#