[#BloombergLP-bslma-ManagedPtr-0fa-2constructor-07] = 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 `*ptr`, and having a deleter that will call `factory‐>deleteObject(ptr)` to destroy the managed object when invoked (e.g., when this managed pointer object is destroyed), unless `0 == ptr`, in which case create an empty managed pointer. The deleter will invoke the destructor of `MANAGED_TYPE` rather than the destructor of `TARGET_TYPE`. This constructor will not compile unless `MANAGED_TYPE *` is convertible to `TARGET_TYPE *`. The behavior is undefined unless the managed object (if any) can be destroyed by the specified `factory`, or if `0 == factory && 0 != ptr`, or if the lifetime of the managed object is already managed by another object. Note that `bslma::Allocator`, and any class publicly and unambiguously derived from `bslma::Allocator`, meets the requirements for `FACTORY_TYPE`. == Synopsis Declared in `<bslma_managedptr.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class MANAGED_TYPE, class FACTORY_TYPE> ManagedPtr( MANAGED_TYPE* ptr, FACTORY_TYPE* factory); ---- [.small]#Created with https://www.mrdocs.com[MrDocs]#