This allows passing the function as a template parameter instead of requiring a custom deleter functor.