std::get_deleter (3) - Linux Manuals
std::get_deleter: std::get_deleter
NAME
std::get_deleter - std::get_deleter
Synopsis
template< class Deleter, class T > (since C++11)
Deleter* get_deleter( const std::shared_ptr<T>& p ) noexcept;
Access to the p's deleter. If the shared pointer p owns a deleter of type cv-unqualified Deleter (e.g. if it was created with one of the constructors that take a deleter as a parameter), then returns a pointer to the deleter. Otherwise, returns a null pointer.
Parameters
p - a shared pointer whose deleter needs to be accessed
Return value
A pointer to the owned deleter or nullptr. The returned pointer is valid at least as long as there remains at least one shared_ptr instance that owns it.
Notes
The returned pointer may outlive the last shared_ptr if, for example, std::weak_ptrs remain and the implementation doesn't destroy the deleter until the entire control block is destroyed.
Example
demonstrates that shared_ptr deleter is independent of the shared_ptr's type
// Run this code
Output:
See also
constructor (public member function)