次の方法で共有


auto_ptr::operator=

An assignment operator that transfers ownership from one auto_ptr object to another.

template<class Other>
   auto_ptr<Type>& operator=(
      auto_ptr<Other>& _Right
   ) throw( );
auto_ptr<Type>& operator=(
   auto_ptr<Type>& _Right
) throw( );
auto_ptr<Type>& operator=(
   auto_ptr_ref<Type> _Right
) throw( );

Parameters

  • _Right
    An object of type auto_ptr.

Return Value

A reference to an object of type auto_ptr<Type>.

Remarks

The assignment evaluates the expression delete myptr, but only if the stored pointer myptr changes as a result of the assignment. It then transfers ownership of the pointer stored in _Right, by storing _Right.release in myptr. The function returns *this.

Example

For an example of the use of the member operator, see auto_ptr::auto_ptr.

Requirements

Header: <memory>

Namespace: std

See Also

Reference

auto_ptr Class

Other Resources

auto_ptr Members