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

Constructors

== Synopses

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

Create an empty managed pointer&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:BloombergLP/bslma/ManagedPtr-0fa/2constructor-01f.adoc[ManagedPtr]();
----

[.small]#xref:BloombergLP/bslma/ManagedPtr-0fa/2constructor-01f.adoc[_» more&period;&period;&period;_]#

Create a managed pointer by taking ownership from `original`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:BloombergLP/bslma/ManagedPtr-0fa/2constructor-008.adoc[ManagedPtr](xref:BloombergLP/bslma/ManagedPtr-0fa.adoc[ManagedPtr]& original) noexcept;
----

[.small]#xref:BloombergLP/bslma/ManagedPtr-0fa/2constructor-008.adoc[_» more&period;&period;&period;_]#

Create a managed pointer by taking ownership from compatible `original`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class BDE&lowbar;OTHER&lowbar;TYPE&gt;
xref:BloombergLP/bslma/ManagedPtr-0fa/2constructor-09.adoc[ManagedPtr](xref:BloombergLP/bslma/ManagedPtr-0fa.adoc[ManagedPtr&lt;BDE&lowbar;OTHER&lowbar;TYPE&gt;]&& original) noexcept
requires bsl&colon;&colon;is&lowbar;convertible&lt;BDE&lowbar;OTHER&lowbar;TYPE &ast;, TARGET&lowbar;TYPE &ast;&gt;&colon;&colon;value;
----

[.small]#xref:BloombergLP/bslma/ManagedPtr-0fa/2constructor-09.adoc[_» more&period;&period;&period;_]#

Create an empty managed pointer from a null pointer literal&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:BloombergLP/bslma/ManagedPtr-0fa/2constructor-06.adoc[ManagedPtr](xref:bsl/nullptr_t-08.adoc[bsl::nullptr&lowbar;t] nullPointerLiteral);
----

[.small]#xref:BloombergLP/bslma/ManagedPtr-0fa/2constructor-06.adoc[_» more&period;&period;&period;_]#

Create a managed pointer by taking ownership from `ref`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:BloombergLP/bslma/ManagedPtr-0fa/2constructor-0b.adoc[ManagedPtr](xref:BloombergLP/bslma/ManagedPtr_Ref.adoc[ManagedPtr&lowbar;Ref&lt;TARGET&lowbar;TYPE&gt;] ref) noexcept;
----

[.small]#xref:BloombergLP/bslma/ManagedPtr-0fa/2constructor-0b.adoc[_» more&period;&period;&period;_]#

Create a managed pointer by taking ownership from `original`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:BloombergLP/bslma/ManagedPtr-0fa/2constructor-052c.adoc[ManagedPtr](xref:BloombergLP/bslmf/MovableRef.adoc[bslmf::MovableRef&lt;ManagedPtr&gt;] original) noexcept;
----

[.small]#xref:BloombergLP/bslma/ManagedPtr-0fa/2constructor-052c.adoc[_» more&period;&period;&period;_]#

Create a managed pointer owning `&ast;ptr`, destroyed with `delete`&period;


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

[.small]#xref:BloombergLP/bslma/ManagedPtr-0fa/2constructor-083.adoc[_» more&period;&period;&period;_]#

Create an empty managed pointer from two null&hyphen;pointer literals&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
explicit
xref:BloombergLP/bslma/ManagedPtr-0fa/2constructor-012.adoc[ManagedPtr](
    xref:bsl/nullptr_t-08.adoc[bsl::nullptr&lowbar;t] nullPointerLiteral,
    xref:bsl/nullptr_t-08.adoc[bsl::nullptr&lowbar;t] cookieNullPointerLiteral);
----

[.small]#xref:BloombergLP/bslma/ManagedPtr-0fa/2constructor-012.adoc[_» more&period;&period;&period;_]#

Create an empty managed pointer&semi; `factory` is ignored&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class FACTORY&lowbar;TYPE&gt;
xref:BloombergLP/bslma/ManagedPtr-0fa/2constructor-0a.adoc[ManagedPtr](
    xref:bsl/nullptr_t-08.adoc[bsl::nullptr&lowbar;t] nullPointerLiteral,
    FACTORY&lowbar;TYPE* factory);
----

[.small]#xref:BloombergLP/bslma/ManagedPtr-0fa/2constructor-0a.adoc[_» more&period;&period;&period;_]#

Create an aliasing managed pointer from `alias` targeting `ptr`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class ALIASED&lowbar;TYPE&gt;
xref:BloombergLP/bslma/ManagedPtr-0fa/2constructor-0524.adoc[ManagedPtr](
    xref:BloombergLP/bslma/ManagedPtr-0fa.adoc[ManagedPtr&lt;ALIASED&lowbar;TYPE&gt;]& alias,
    TARGET&lowbar;TYPE* ptr);
----

[.small]#xref:BloombergLP/bslma/ManagedPtr-0fa/2constructor-0524.adoc[_» more&period;&period;&period;_]#

Move&hyphen;construct an aliasing managed pointer from `alias` targeting `ptr`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class ALIASED&lowbar;TYPE&gt;
xref:BloombergLP/bslma/ManagedPtr-0fa/2constructor-0d3.adoc[ManagedPtr](
    xref:BloombergLP/bslma/ManagedPtr-0fa.adoc[ManagedPtr&lt;ALIASED&lowbar;TYPE&gt;]&& alias,
    TARGET&lowbar;TYPE* ptr);
----

[.small]#xref:BloombergLP/bslma/ManagedPtr-0fa/2constructor-0d3.adoc[_» more&period;&period;&period;_]#

Create a managed pointer owning `&ast;ptr`, destroyed via `factory`&period;


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

[.small]#xref:BloombergLP/bslma/ManagedPtr-0fa/2constructor-07.adoc[_» more&period;&period;&period;_]#

Create a managed pointer owning `&ast;ptr` with the specified deleter&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:BloombergLP/bslma/ManagedPtr-0fa/2constructor-0e.adoc[ManagedPtr](
    TARGET&lowbar;TYPE* ptr,
    void* cookie,
    xref:BloombergLP/bslma/ManagedPtr-0fa/DeleterFunc.adoc[DeleterFunc] deleter);
----

[.small]#xref:BloombergLP/bslma/ManagedPtr-0fa/2constructor-0e.adoc[_» more&period;&period;&period;_]#

Create a managed pointer owning `&ast;ptr` with the specified deleter&period;


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

[.small]#xref:BloombergLP/bslma/ManagedPtr-0fa/2constructor-006.adoc[_» more&period;&period;&period;_]#

Create a managed pointer owning `&ast;ptr` with the specified deleter&period;


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

[.small]#xref:BloombergLP/bslma/ManagedPtr-0fa/2constructor-086.adoc[_» more&period;&period;&period;_]#

Create a managed pointer owning `&ast;ptr` with the specified deleter&period;


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

[.small]#xref:BloombergLP/bslma/ManagedPtr-0fa/2constructor-0d9.adoc[_» more&period;&period;&period;_]#

== Parameters

[cols="1,4"]
|===
| Name| Description
| *original*
| managed pointer from which to take ownership
| *nullPointerLiteral*
| null&hyphen;pointer literal (unused&semi; selects this overload)
| *ref*
| managed&hyphen;pointer reference from which to take ownership
| *ptr*
| pointer to the object to manage, or null
| *cookieNullPointerLiteral*
| null&hyphen;pointer literal (unused&semi; selects this overload)
| *factory*
| unused factory pointer
| *alias*
| managed pointer supplying ownership of the managed object
| *cookie*
| cookie passed to `deleter` when the object is destroyed
| *deleter*
| function used to destroy the managed object
|===


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