std::shared_ptr::reset

From Cppreference

Jump to: navigation, search
void reset() noexcept;
(1)
template< class Y >
void reset( Y* ptr );
(2)
template< class Y, class Deleter >
void reset( Y* ptr, Deleter d );
(3)
template< class Y, class Deleter, class Allocator >
void reset( Y* ptr, Deleter d, Allocator alloc );
(4)

Replaces the managed object with an object pointed to by ptr. Optional deleter d can be supplied, which is later used to destroy the new object when no shared_ptr objects own it. By default, delete expression is used as deleter. Proper delete expression corresponding to the supplied type is always selected, this is the reason why the function is implemented as template using a separate parameter Y.

If *this already owns an object and it is the last shared_ptr owning it, the object is destroyed through the owned deleter, unless ptr is a pointer to it.

Contents

[edit] Parameters

[edit] Return value

(none)

[edit] Example

[edit] See also