[#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 `<bslma_managedptr.h>` Destroy the currently managed object, if any. Then, set the target object of this managed pointer to be that referenced by the specified `ptr`, take ownership of `*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.g., when this managed pointer object is destroyed), unless `0 == ptr`, in which case reset this managed pointer to empty. The deleter will invoke the destructor of `MANAGED_TYPE` rather than the destructor of `TARGET_TYPE`. This function 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 currently installed default allocator, or if the lifetime of the managed object is already managed by another object. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class MANAGED_TYPE> void xref:BloombergLP/bslma/ManagedPtr-0fa/load-0e.adoc[load](MANAGED_TYPE* ptr); ---- [.small]#xref:BloombergLP/bslma/ManagedPtr-0fa/load-0e.adoc[_» more..._]# Destroy the currently managed object, if any. Then, set the target object of this managed pointer to be that referenced by the specified `ptr`, take ownership of `*ptr` as the currently managed object, and set a deleter that calls `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 reset this managed pointer to empty. The deleter will invoke the destructor of `MANAGED_TYPE` rather than the destructor of `TARGET_TYPE`. This function 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 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`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class MANAGED_TYPE, class FACTORY_TYPE> void xref:BloombergLP/bslma/ManagedPtr-0fa/load-03.adoc[load]( MANAGED_TYPE* ptr, FACTORY_TYPE* factory); ---- [.small]#xref:BloombergLP/bslma/ManagedPtr-0fa/load-03.adoc[_» more..._]# Destroy the current managed object (if any) and reset this managed pointer to empty. Note that the optionally specified `cookie` and `deleter` will be ignored, as empty managed pointers do not invoke a deleter. [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_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..._]# Destroy the currently managed object, if any. Then, set the target object of this managed pointer to be that referenced by the specified `ptr`, take ownership of `*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 == ptr`, in which case reset this managed pointer to empty. The behavior is undefined if `ptr` is already managed by another object, or if `0 == deleter && 0 != ptr`. Note that GCC 3.4 and earlier versions have a bug in template type deduction/overload resolution that causes ambiguities if this signature is available. This function will be restored on that platform once the deprecated signatures are finally removed. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class MANAGED_TYPE> void xref:BloombergLP/bslma/ManagedPtr-0fa/load-0d8.adoc[load]( MANAGED_TYPE* ptr, void* cookie, xref:BloombergLP/bslma/ManagedPtr-0fa/DeleterFunc.adoc[DeleterFunc] deleter); ---- [.small]#xref:BloombergLP/bslma/ManagedPtr-0fa/load-0d8.adoc[_» more..._]# DEPRECATED: Use the non‐template `load` overload instead. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class MANAGED_TYPE, class COOKIE_TYPE> void xref:BloombergLP/bslma/ManagedPtr-0fa/load-0dd.adoc[load]( MANAGED_TYPE* ptr, COOKIE_TYPE* cookie, xref:BloombergLP/bslma/ManagedPtr-0fa/DeleterFunc.adoc[DeleterFunc] deleter); ---- [.small]#xref:BloombergLP/bslma/ManagedPtr-0fa/load-0dd.adoc[_» more..._]# DEPRECATED: Use the non‐template `load` overload instead. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class MANAGED_TYPE, class MANAGED_BASE> void xref:BloombergLP/bslma/ManagedPtr-0fa/load-0a.adoc[load]( MANAGED_TYPE* ptr, void* cookie, void(* deleter)(MANAGED_BASE*, void*)); ---- [.small]#xref:BloombergLP/bslma/ManagedPtr-0fa/load-0a.adoc[_» more..._]# Destroy the currently managed object, if any. Then, set the target object of this managed pointer to be that referenced by the specified `ptr`, take ownership of `*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 == ptr`, in which case reset this managed pointer to empty. 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, but luckily perform as required for all currently supported platforms; on platforms where the non‐deprecated overload is not available (e.g., GCC 3.4) code should be written as if it were available, as an appropriate (deprecated) overload will be selected with the correct (non‐deprecated) behavior. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class MANAGED_TYPE, class MANAGED_BASE, class COOKIE_TYPE, class COOKIE_BASE> void xref:BloombergLP/bslma/ManagedPtr-0fa/load-06.adoc[load]( MANAGED_TYPE* ptr, COOKIE_TYPE* cookie, void(* deleter)(MANAGED_BASE*, COOKIE_BASE*)); ---- [.small]#xref:BloombergLP/bslma/ManagedPtr-0fa/load-06.adoc[_» more..._]# [.small]#Created with https://www.mrdocs.com[MrDocs]#