Megosztás a következőn keresztül:


unique_ptr::reset

Takes ownership of the pointer parameter, and then deletes the original stored pointer. If the new pointer is the same as the original stored pointer, reset deletes the pointer and sets the stored pointer to nullptr.

void reset(pointer ptr = pointer());
void reset(nullptr_t ptr);

Parameters

Parameter

Description

ptr

A pointer to the resource to take ownership of.

Remarks

Use reset to change the stored pointer owned by the unique_ptr to ptr and then delete the original stored pointer. If the unique_ptr was not empty, reset invokes the deleter function returned by get_deleter on the original stored pointer.

Because reset first stores the new pointer ptr, and then deletes the original stored pointer, it's possible for reset to immediately delete ptr if it is the same as the original stored pointer.

Requirements

Header: <memory>

Namespace: std

See Also

Reference

unique_ptr Class

<memory>

Other Resources

<memory> Members