[#BloombergLP-bslma-ManagedPtr-0fa-2constructor-0d9] = 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 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 == ptr`, in which case create an empty managed pointer. This constructor will not compile unless `MANAGED_TYPE *` is convertible to `TARGET_TYPE *`, and `MANAGED_TYPE *` is convertible to `MANAGED_BASE *`. The deleter will invoke the destructor of `MANAGED_TYPE` rather than the destructor of `TARGET_TYPE`. The behavior is undefined if `ptr` is already managed by another object, or if `0 == deleter && 0 != ptr`. Note that this function is _deprecated_ as it relies on undefined compiler behavior for its implementation (that luckily performs as required on every platform supported by BDE). == Synopsis Declared in `<bslma_managedptr.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class MANAGED_TYPE, class MANAGED_BASE, class COOKIE_TYPE, class COOKIE_BASE> ManagedPtr( MANAGED_TYPE* ptr, COOKIE_TYPE* cookie, void(* deleter)(MANAGED_BASE*, COOKIE_BASE*)); ---- == Description DEPRECATED: Instead, use: ` template <class MANAGED_TYPE> ManagedPtr(MANAGED_TYPE *ptr, void *cookie, DeleterFunc deleter); ` [.small]#Created with https://www.mrdocs.com[MrDocs]#