C++ Language/Indirection/SmartPointers/CustomDestruction

Normally you rely on a smart pointer to decide both "when" and "how" to deallocate. But it is possible for you to provide a custom callable-object for the "how" part.

Additional information about smart pointers using custom destruction (includes interactive examples)