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 21:09:36 -0300
Correct. In fact, the idea for this core building block came from my
library to emulate flexible array members in C++ (
https://github.com/brenoguim/flexclass ) in a more powerful way.
I suspect that we rarely see a variable number of contiguous objects in C++
exactly because it's awfully complex to safely implement it.

Thanks for your feedback!
Breno G.



On Mon, Apr 25, 2022 at 9:01 PM Thiago Macieira <thiago_at_[hidden]> wrote:

> On Monday, 25 April 2022 16:49:31 PDT Breno Guimarães wrote:
> > 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);
>
> No, it's not changeable at runtime, but neither are most uses of these
> contiguous objects. In the vast majority of uses I've seen so far, the
> offsets
> are computed statically, which means it must be known at compile time.
>
> The array case is an interesting one and is the exception. That smells
> like
> C99's Flexible Array Member, though, which C++ refused to implement for a
> number of reasons.
>
> I personally think it's useful.
>
> --
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
> Software Architect - Intel DPG Cloud Engineering
>
>
>
>

Received on 2022-04-26 00:09:48