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

Smart pointer with sole ownership of a managed object and a possibly distinct target&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class TARGET&lowbar;TYPE&gt;
class ManagedPtr;
----

== Description

This class is a &quot;smart pointer&quot; that refers to a _target_ object accessed via a pointer to the specified parameter type, `TARGET&lowbar;TYPE`, and that supports sole ownership of a _managed_ object that is potentially of a different type, and may be an entirely different object from the target object&period; A managed pointer ensures that the object it manages is destroyed when the managed pointer is destroyed (or re&hyphen;assigned), using the &quot;deleter&quot; supplied along with the managed object&period; The target object referenced by a managed pointer may be accessed using either the `&hyphen;&gt;` operator, or the dereference operator (`operator &ast;`)&period; The specified `TARGET&lowbar;TYPE` may be `const`&hyphen;qualified, but may not be `volatile`&hyphen;qualified, nor may it be a reference type&period;

A managed pointer may be _empty_, in which case it neither refers to a target object nor owns a managed object&period; An empty managed pointer is the equivalent of a null pointer&colon; Such a managed pointer is not de&hyphen;referenceable, and tests as `false` in boolean expressions&period;

A managed pointer for which the managed object is not the same object as the target is said to _alias_ the managed object (see the section &quot;Aliasing&quot; in the component&hyphen;level documentation)&period;

== Type Aliases

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bslma/ManagedPtr-0fa/DeleterFunc.adoc[`DeleterFunc`] 
| Alias for a function&hyphen;pointer type for functions used to destroy the object managed by a `ManagedPtr` object&period;
| xref:BloombergLP/bslma/ManagedPtr-0fa/element_type.adoc[`element&lowbar;type`] 
| Alias to the `TARGET&lowbar;TYPE` template parameter&period;
|===


== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bslma/ManagedPtr-0fa/2constructor-0c.adoc[`ManagedPtr`]         [.small]#[constructor]#
| Constructors
| xref:BloombergLP/bslma/ManagedPtr-0fa/2destructor.adoc[`&#126;ManagedPtr`] [.small]#[destructor]#
| Destroy this managed pointer and its managed object (if any)&period;
| xref:BloombergLP/bslma/ManagedPtr-0fa/operator_assign-09.adoc[`operator&equals;`] 
| Assignment operators
| xref:BloombergLP/bslma/ManagedPtr-0fa/clear.adoc[`clear`] 
| Destroy the current managed object (if any) and reset this managed pointer to empty&period;
| xref:BloombergLP/bslma/ManagedPtr-0fa/deleter.adoc[`deleter`] 
| Return a reference to the non&hyphen;modifiable deleter information associated with this managed pointer&period; The behavior is undefined if this managed pointer is empty&period;
| xref:BloombergLP/bslma/ManagedPtr-0fa/get.adoc[`get`] 
| Return the address of the target object, or 0 if this managed pointer is empty&period;
| xref:BloombergLP/bslma/ManagedPtr-0fa/load-0b.adoc[`load`] 
| `load` overloads
| xref:BloombergLP/bslma/ManagedPtr-0fa/loadAlias.adoc[`loadAlias`] 
| Retarget or transfer ownership using the aliasing pointer `alias`&period;
| xref:BloombergLP/bslma/ManagedPtr-0fa/operator_star.adoc[`operator&ast;`] 
| Return a reference to the target object&period; The behavior is undefined if this managed pointer is empty, or if `TARGET&lowbar;TYPE` is `void` or `const void`&period;
| xref:BloombergLP/bslma/ManagedPtr-0fa/operator_ptr.adoc[`operator&hyphen;&gt;`] 
| Return the address of the target object, or 0 if this managed pointer is empty&period;
| xref:BloombergLP/bslma/ManagedPtr-0fa/ptr.adoc[`ptr`] 
| Return the address of the target object, or 0 if this managed pointer is empty&period;
| xref:BloombergLP/bslma/ManagedPtr-0fa/release-05.adoc[`release`] 
| `release` overloads
| xref:BloombergLP/bslma/ManagedPtr-0fa/reset.adoc[`reset`] 
| Destroy the current managed object (if any) and reset this managed pointer to empty&period;
| xref:BloombergLP/bslma/ManagedPtr-0fa/swap.adoc[`swap`] 
| Exchange the value and ownership of this managed pointer with `other`&period;
| xref:BloombergLP/bslma/ManagedPtr-0fa/2conversion-0a.adoc[`operator BoolType`] 
| Return whether this managed pointer is non&hyphen;empty&period;
| xref:BloombergLP/bslma/ManagedPtr-0fa/2conversion-0b.adoc[`operator ManagedPtr&lowbar;Ref&lt;REFERENCED&lowbar;TYPE&gt;`] 
| Return a managed&hyphen;pointer reference to this object&period;
| xref:BloombergLP/bslma/ManagedPtr-0fa/operator_eq.adoc[`operator&equals;&equals;`] 
| Return `true` if this managed pointer is empty, and `false` otherwise&period;
| xref:BloombergLP/bslma/ManagedPtr-0fa/operator_not_eq.adoc[`operator!&equals;`] 
| Return `false` if this managed pointer is empty, and `true` otherwise&period;
|===


== Specializations

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bslma/ManagedPtr-0fd.adoc[`ManagedPtr&lt;TARGET&lowbar;TYPE volatile&gt;`] 
| Incomplete specialization that rejects `ManagedPtr` to `volatile` types&period;
| xref:BloombergLP/bslma/ManagedPtr-04.adoc[`ManagedPtr&lt;TARGET&lowbar;TYPE&&gt;`] 
| Incomplete specialization that rejects `ManagedPtr` to reference types&period;
| xref:BloombergLP/bslma/ManagedPtr-09.adoc[`ManagedPtr&lt;TARGET&lowbar;TYPE&&&gt;`] 
| Incomplete specialization that rejects `ManagedPtr` to rvalue references&period;
|===


== Friends

[cols="1,4"]
|===
| Name| Description
| `BloombergLP::bslma::ManagedPtr`
| Smart pointer with sole ownership of a managed object and a possibly distinct target&period;
|===

== Non-Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bslma/swap.adoc[`swap`]
| Efficiently exchange the values of the specified `a` and `b` objects&period; This function provides the no&hyphen;throw exception&hyphen;safety guarantee&period;
|===


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