[#BloombergLP-bslma-ManagedPtr-0fa-load-0b]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslma.adoc[bslma]::xref:BloombergLP/bslma/ManagedPtr-0fa.adoc[ManagedPtr]::load
:relfileprefix: ../../../
:mrdocs:

`load` overloads

== Synopses

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

Destroy the currently managed object, if any&period; Then, set the target object of this managed pointer to be that referenced by the specified `ptr`, take ownership of `&ast;ptr` as the currently managed object, and set a deleter that uses the currently installed default allocator to destroy the managed object when invoked (e&period;g&period;, when this managed pointer object is destroyed), unless `0 &equals;&equals; ptr`, in which case reset this managed pointer to empty&period; The deleter will invoke the destructor of `MANAGED&lowbar;TYPE` rather than the destructor of `TARGET&lowbar;TYPE`&period; This function will not compile unless `MANAGED&lowbar;TYPE &ast;` is convertible to `TARGET&lowbar;TYPE &ast;`&period; The behavior is undefined unless the managed object (if any) can be destroyed by the currently installed default allocator, or if the lifetime of the managed object is already managed by another object&period;


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

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

Destroy the currently managed object, if any&period; Then, set the target object of this managed pointer to be that referenced by the specified `ptr`, take ownership of `&ast;ptr` as the currently managed object, and set a deleter that calls `factory&hyphen;&gt;deleteObject(ptr)` to destroy the managed object when invoked (e&period;g&period;, when this managed pointer object is destroyed), unless `0 &equals;&equals; ptr`, in which case reset this managed pointer to empty&period; The deleter will invoke the destructor of `MANAGED&lowbar;TYPE` rather than the destructor of `TARGET&lowbar;TYPE`&period; This function will not compile unless `MANAGED&lowbar;TYPE &ast;` is convertible to `TARGET&lowbar;TYPE &ast;`&period; The behavior is undefined unless the managed object (if any) can be destroyed by the specified `factory`, or if `0 &equals;&equals; factory &amp;&amp; 0 !&equals; ptr`, or if the the lifetime of the managed object is already managed by another object&period; Note that `bslma&colon;&colon;Allocator`, and any class publicly and unambiguously derived from `bslma&colon;&colon;Allocator`, meets the requirements for `FACTORY&lowbar;TYPE`&period;


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

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

Destroy the current managed object (if any) and reset this managed pointer to empty&period; Note that the optionally specified `cookie` and `deleter` will be ignored, as empty managed pointers do not invoke a deleter&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
void
xref:BloombergLP/bslma/ManagedPtr-0fa/load-09.adoc[load](
    xref:bsl/nullptr_t-08.adoc[bsl::nullptr&lowbar;t] = 0,
    void* cookie = 0,
    xref:BloombergLP/bslma/ManagedPtr-0fa/DeleterFunc.adoc[DeleterFunc] deleter = 0);
----

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

Destroy the currently managed object, if any&period; Then, set the target object of this managed pointer to be that referenced by the specified `ptr`, take ownership of `&ast;ptr` as the currently managed object, and set 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 reset this managed pointer to empty&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; Note that GCC 3&period;4 and earlier versions have a bug in template type deduction&sol;overload resolution that causes ambiguities if this signature is available&period; This function will be restored on that platform once the deprecated signatures are finally removed&period;


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

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

DEPRECATED&colon; Use the non&hyphen;template `load` overload instead&period;


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

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

DEPRECATED&colon; Use the non&hyphen;template `load` overload instead&period;


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

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

Destroy the currently managed object, if any&period; Then, set the target object of this managed pointer to be that referenced by the specified `ptr`, take ownership of `&ast;ptr` as the currently managed object, and set 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 reset this managed pointer to empty&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; Note that this function is _deprecated_ as it relies on undefined compiler behavior for its implementation, but luckily perform as required for all currently supported platforms&semi; on platforms where the non&hyphen;deprecated overload is not available (e&period;g&period;, GCC 3&period;4) code should be written as if it were available, as an appropriate (deprecated) overload will be selected with the correct (non&hyphen;deprecated) behavior&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;
void
xref:BloombergLP/bslma/ManagedPtr-0fa/load-06.adoc[load](
    MANAGED&lowbar;TYPE* ptr,
    COOKIE&lowbar;TYPE* cookie,
    void(* deleter)(MANAGED&lowbar;BASE*, COOKIE&lowbar;BASE*));
----

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


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