std::shared_ptr<T>::~shared_ptr

From cppreference.com
< cpp‎ | memory‎ | shared ptr
 
 
Utilities library
General utilities
Date and time
Function objects
Formatting library (C++20)
(C++11)
Relational operators (deprecated in C++20)
Integer comparison functions
(C++20)
Swap and type operations
(C++14)
(C++11)
(C++11)
(C++11)
(C++17)
Common vocabulary types
(C++11)
(C++17)
(C++17)
(C++17)
(C++17)

Elementary string conversions
(C++17)
(C++17)
 
Dynamic memory management
Smart pointers
(C++11)
(C++11)
(C++11)
(until C++17)
(C++11)
Allocators
Memory resources
Uninitialized storage
Uninitialized memory algorithms
Constrained uninitialized memory algorithms
Garbage collection support
Miscellaneous
(C++20)
(C++11)
(C++11)
C Library
Low level memory management
 
 
~shared_ptr();

If *this owns an object and it is the last shared_ptr owning it, the object is destroyed through the owned deleter.

After the destruction, the smart pointers that shared ownership with *this, if any, will report a use_count() that is one less than its previous value.

Notes

Unlike std::unique_ptr, the deleter of std::shared_ptr is invoked even if the managed pointer is null.

Example

See also

destroys a weak_ptr
(public member function of std::weak_ptr<T>)