Date: Tue, 24 Aug 2021 01:04:42 +0300
On Tue, 24 Aug 2021 at 00:46, Thiago Macieira via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> On Monday, 23 August 2021 09:56:58 PDT Ville Voutilainen via Std-Proposals
> wrote:
> > > Fundamentally unique_ptr
> > > stores the deleter only in the type, which I think means the
> >
> > > deleter function can only ever be a template parameter:
> > I don't quite follow. unique_ptr does store a deleter object, not just
> > its type. It has
> > http://eel.is/c++draft/unique.ptr.single.ctor#10 for exactly this purpose.
>
> True, but you may want to encode everything in the type, to avoid storing an
> extra 8 bytes to make the indirect function call. That's likely the most
> common use-case, as TIFF* gets freed with TIFFClose and FILE* with fclose. Of
> course, if you do that, you'd have to use a different std::unique_ptr
> instantiation if you want your FILE* to be closed with pclose instead.
I can do that without changing the client-side invocation of this
function too much:
https://wandbox.org/permlink/NBG9PbfxHbNniudX
<std-proposals_at_[hidden]> wrote:
>
> On Monday, 23 August 2021 09:56:58 PDT Ville Voutilainen via Std-Proposals
> wrote:
> > > Fundamentally unique_ptr
> > > stores the deleter only in the type, which I think means the
> >
> > > deleter function can only ever be a template parameter:
> > I don't quite follow. unique_ptr does store a deleter object, not just
> > its type. It has
> > http://eel.is/c++draft/unique.ptr.single.ctor#10 for exactly this purpose.
>
> True, but you may want to encode everything in the type, to avoid storing an
> extra 8 bytes to make the indirect function call. That's likely the most
> common use-case, as TIFF* gets freed with TIFFClose and FILE* with fclose. Of
> course, if you do that, you'd have to use a different std::unique_ptr
> instantiation if you want your FILE* to be closed with pclose instead.
I can do that without changing the client-side invocation of this
function too much:
https://wandbox.org/permlink/NBG9PbfxHbNniudX
Received on 2021-08-23 17:04:55