C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Floating the idea for std::make_contiguous_objects

From: Breno Guimarães <brenorg_at_[hidden]>
Date: Mon, 25 Apr 2022 20:49:31 -0300
Hi Thiago,

Thanks for your reply. I think you missed that one key functionality here
is to allow a runtime number of each "T".

Going back to the example of std::make_shared<int[]>, I would be able to
create the control block + "n" ints with:

auto objs = make_contiguous_objects<ControlBlock, int>(1, *n*);

Best Regards,
Breno Guimarães



On Mon, Apr 25, 2022 at 8:38 PM Thiago Macieira via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> On Monday, 25 April 2022 16:23:37 PDT Breno Guimarães via Std-Proposals
> wrote:
> > template<class... Ts>
> > std::tuple<std::pair<Ts*, Ts*>...>
> > make_contiguous_objects(initializer_for<Ts>...);
>
> std::tuple is already your answer.
>
> If you're going to leave the layout to the implementation, then it means
> you
> don't care about exact offsets inside the allocated memory. That means
> std::tuple with its empty base optimisations and support for final does
> what
> you want it to do.
>
> You don't need make_contiguous_objects<T...>(). All you need is
> std::tuple<T...>.
>
> --
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
> Software Architect - Intel DPG Cloud Engineering
>
>
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2022-04-25 23:49:43