Assignment operators

Synopses

Declared in <bslma_managedptr.h>

If this object and the specified rhs manage the same object, return a reference to this managed pointer; otherwise, destroy the managed object owned by this managed pointer, transfer ownership of the managed object owned by rhs to this managed pointer, set this managed pointer to point to the target object referenced by rhs, reset rhs to empty, and return a reference to this managed pointer.

If this object and the specified rhs manage the same object, return a reference to this managed pointer; otherwise, destroy the managed object owned by this managed pointer, transfer ownership of the managed object owned by rhs to this managed pointer, set this managed pointer to point to the target object referenced by rhs, reset rhs to empty, and return a reference to this managed pointer. TARGET_TYPE must be an accessible and unambiguous base of BDE_OTHER_TYPE.

template<class BDE_OTHER_TYPE>
ManagedPtr<TARGET_TYPE>&
operator=(ManagedPtr<BDE_OTHER_TYPE>&& rhs) noexcept
requires bsl::is_convertible<BDE_OTHER_TYPE *, TARGET_TYPE *>::value;

Destroy the current managed object (if any) and reset this managed pointer to empty.

If this object and the managed pointer reference by the specified ref manage the same object, return a reference to this managed pointer; otherwise, destroy the managed object owned by this managed pointer, transfer ownership of the managed object owned by the managed pointer referenced by ref, and set this managed pointer to point to the target object currently referenced the managed pointer referenced by ref; then reset the managed pointer referenced by ref to empty, and return a reference to this managed pointer. This operator is (implicitly) used to assign from a managed pointer rvalue, or from a managed pointer to a "compatible" type, where "compatible" means a built‐in conversion from MANAGED_TYPE * to TARGET_TYPE * is defined, e.g., derived * to base *, T * to const T *, or T * to void *.

If this object and the specified rhs manage the same object, return a reference to this managed pointer; otherwise, destroy the managed object owned by this managed pointer, transfer ownership of the managed object owned by rhs to this managed pointer, set this managed pointer to point to the target object referenced by rhs, reset rhs to empty, and return a reference to this managed pointer.

Created with MrDocs