[#BloombergLP-bslma-ManagedPtr-0fa-2constructor-006]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslma.adoc[bslma]::xref:BloombergLP/bslma/ManagedPtr-0fa.adoc[ManagedPtr]::ManagedPtr
:relfileprefix: ../../../
:mrdocs:

Create a managed pointer having a target object referenced by the specified `ptr`, owning the managed object `&ast;ptr`, and having a deleter that will invoke the specified `deleter` with the address of the currently managed object, and with the specified `cookie` (that the deleter can use for its own purposes), unless `0 &equals;&equals; ptr`, in which case create an empty managed pointer&period; This constructor will not compile unless `MANAGED&lowbar;TYPE &ast;` is convertible to `TARGET&lowbar;TYPE &ast;`&period; The deleter will invoke the destructor of `MANAGED&lowbar;TYPE` rather than the destructor of `TARGET&lowbar;TYPE`&period; The behavior is undefined if `ptr` is already managed by another object, or if `0 &equals;&equals; deleter &amp;&amp; 0 !&equals; ptr`&period;

== Synopsis

Declared in `&lt;bslma&lowbar;managedptr&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class MANAGED&lowbar;TYPE&gt;
ManagedPtr(
    MANAGED&lowbar;TYPE* ptr,
    void* cookie,
    xref:BloombergLP/bslma/ManagedPtr-0fa/DeleterFunc.adoc[DeleterFunc] deleter);
----


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