C++ Logo

std-proposals

Advanced search

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

From: Thiago Macieira <thiago_at_[hidden]>
Date: Mon, 25 Apr 2022 17:01:01 -0700
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:01:03