C++ Logo

std-proposals

Advanced search

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

From: Arthur O'Dwyer <arthur.j.odwyer_at_[hidden]>
Date: Mon, 11 Dec 2023 15:35:11 -0500
On Mon, Dec 11, 2023 at 3:15 PM Frederick Virchanza Gotham via
Std-Proposals <std-proposals_at_[hidden]> wrote:

> On Mon, Dec 11, 2023 at 1:28 AM connor horman wrote:
> >
> > As a note about `std::unaligned`, it's possible to implement
> > `unaligned` in C++20 in fully standards compliant code.
> > https://godbolt.org/z/MsWhsjoW3
>
> Connor I've taken your code and made a few changes:
> (1) I use Arthur's compiler up on Godbolt that has
> 'trivially_relocatable'
>

Thanks :) but I don't think `is_trivially_relocatable` is useful here. You
never relocate-out-of (nor into) a `T` here. And the requirements on `T`
are much stricter than "trivially relocatable"; for example, you actually
need it to be trivially destructible, or else `unaligned<T>` won't have any
destructor.
For example: I don't think it makes sense to talk about
`std::unaligned<std::string>`. I don't know what the semantics of that
would be.

–Arthur

Received on 2023-12-11 20:35:24