BloombergLP::bslma::ManagedPtr::ManagedPtr

Create a managed pointer owning *ptr with the specified deleter.

Synopsis

Declared in <bslma_managedptr.h>

ManagedPtr(
    TARGET_TYPE* ptr,
    void* cookie,
    DeleterFunc deleter);

Description

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. The behavior is undefined if ptr is already managed by another object, or if 0 == deleter && 0 != ptr. Note that this constructor is required only because the deprecated overloads cause an ambiguity in its absence; it should be removed when the deprecated overloads are 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