BloombergLP::bslma::ManagedPtr::load

Take ownership of *ptr with the specified deleter.

Synopsis

Declared in <bslma_managedptr.h>

template<class MANAGED_TYPE>
void
load(
    MANAGED_TYPE* ptr,
    void* cookie,
    DeleterFunc deleter);

Description

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.

Parameters

NameDescription
ptrpointer to the object to manage, or null
cookiecookie passed to deleter when the object is destroyed
deleterfunction used to destroy the managed object