Date: Mon, 04 Dec 2023 11:33:07 -0800
On Sunday, 3 December 2023 23:08:07 PST Frederick Virchanza Gotham via Std-
Proposals wrote:
> On Mon, Dec 4, 2023 at 3:02 AM Arthur O'Dwyer wrote:
> > What I think Thiago meant, and certainly what I mean, is that it's
> > wrong to use [[no_unique_address]] on the `value` member of
> > an `optional` or `expected`.
>
> I think it's fine so long as you make it very obvious that you're not
> allowed to use 'memcpy' or 'memset'. Maybe call it something like:
>
> class optional_compacted_no_memset { . . . };
That's not the same thing as Arthur said. If you want to add a new class that
has those extra constraints on top of std::optional and std::expected, then
sure. He said it's not acceptable to add the attribute to those classes
because they don't have and can't have this extra requirement on the user's
template arguments.
> I was also thinking of writing something along the lines of an
> 'array_compacted' which would be the same as an 'std::array' except
> that the elements have no padding between them, which would be very
> useful for minimising Flash usage on a microcontroller -- something
> like:
You're describing __atribute__((packed)) a.k.a. [[gnu::packed]]. Why not use
that instead?
Proposals wrote:
> On Mon, Dec 4, 2023 at 3:02 AM Arthur O'Dwyer wrote:
> > What I think Thiago meant, and certainly what I mean, is that it's
> > wrong to use [[no_unique_address]] on the `value` member of
> > an `optional` or `expected`.
>
> I think it's fine so long as you make it very obvious that you're not
> allowed to use 'memcpy' or 'memset'. Maybe call it something like:
>
> class optional_compacted_no_memset { . . . };
That's not the same thing as Arthur said. If you want to add a new class that
has those extra constraints on top of std::optional and std::expected, then
sure. He said it's not acceptable to add the attribute to those classes
because they don't have and can't have this extra requirement on the user's
template arguments.
> I was also thinking of writing something along the lines of an
> 'array_compacted' which would be the same as an 'std::array' except
> that the elements have no padding between them, which would be very
> useful for minimising Flash usage on a microcontroller -- something
> like:
You're describing __atribute__((packed)) a.k.a. [[gnu::packed]]. Why not use
that instead?
-- Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org Software Architect - Intel DCAI Cloud Engineering
Received on 2023-12-04 19:33:09