Re: [PATCH 06/24] gdbsupport: make intrusive_list's disposer accept a reference

Simon Marchi
2023-10-14T20:13:01Z

On 10/12/23 15:05, Pedro Alves wrote:
> On 2023-10-10 21:40, Simon Marchi wrote:
>> All the API of intrusive_list works with references to item, I'm not
>> sure why the disposer used in intrusive_list::clear_and_dispose is
>> different and receives a pointer. Change it to accept a reference
>> instead. This helps simplify a bit a subsequent patch, and I don't see
>> any downside to it.
>
> The whole intrusive_list API was copied from Boost intrusive_list (not
> the implementation), so that's where that came from.
>
> I assume that the Disposer interface takes a pointer so that it has the same
> interface as a unique_ptr Deleter, for instance. From a pure disposer/deleter angle,
> it seems a bit odd to me to have a "delete" operator wrapper take a reference
> instead of a pointer, leading to code like "delete &ref", FWIW.
>
> If this doesn't result in a great tangible improvement, I'd prefer keeping
> the interface in sync with Boost's.

I forgot about that, that's a good reason, I'll drop this patch.

Thanks,

Simon