Create an aliasing managed pointer from alias targeting ptr.

Synopsis

Declared in <bslma_managedptr.h>

template<class ALIASED_TYPE>
ManagedPtr(
    ManagedPtr<ALIASED_TYPE>& alias,
    TARGET_TYPE* ptr);

Description

Create a managed pointer that takes ownership of the object managed by the specified alias, but which uses the specified ptr to refer to its target object, unless 0 == ptr, in which case create an empty managed pointer. Reset alias to empty if ownership of its managed object is transferred. The behavior is undefined if alias is empty, but 0 != ptr. Note that destroying or re‐assigning a managed pointer created with this constructor will destroy the object originally managed by alias (unless release is called first); the destructor for *ptr is not called directly.

Parameters

Name

Description

alias

managed pointer supplying ownership of the managed object

ptr

pointer used as the target of this managed pointer, or null

Created with MrDocs