Boost logo

Boost :

Subject: Re: [boost] [smart_ptr] Is there any interest in unique_ptr with type erased deleter?
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2017-03-21 15:00:15


On 03/21/17 17:53, Richard Hodges via Boost wrote:
> A poly_deleter really should not hold just a function pointer as a deleter.
> The custom deleter may be any function, containing any amount of state (it
> could for example be returning resources to a memory pool, or managing a
> semaphore).
>
> fixing the deleter type at `void (*)(void*)` is a no-go. It's not useful.

If you want something more generic then just use std::function as a
deleter. It's been mentioned earlier in the thread.

Personally though, I don't remember needing anything more elaborate than
a `void (*)(void*)` function or similar. Probably because if I need
something more advanced, I'll likely choose a virtual destructor or
shared_ptr or intrusive_ptr. Carrying around a fat deleter in every
pointer instance is what I consider a no-go.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk