C++ Logo

std-proposals

Advanced search

Re: [std-proposals] [[packed]] std::unaligned

From: Thiago Macieira <thiago_at_[hidden]>
Date: Sun, 10 Dec 2023 08:59:16 -0800
On Sunday, 10 December 2023 08:22:23 PST Frederick Virchanza Gotham via Std-
Proposals wrote:
> Lénárd posted the same day:
> > And lift the ban on specifying
> > lower than the types alignment
> > for members.
>
> Actually it would be interesting if we could do the following:
>
> struct Monkey {
> alignas(1) long unsigned a;
> alignas(1) char b;
> alignas(1) long unsigned c;
> alignas(1) char d;
> };

But it would also allow applying the attribute to arbitrary types, which it
shouldn't. The text would need to restrict it to only primitives (or at least
trivial ones) and deny calling members on them.

It's far easier to accomplish the necessary restrictions with a library
solution.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel DCAI Cloud Engineering

Received on 2023-12-10 16:59:17