C++ Logo

std-proposals

Advanced search

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

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Sat, 9 Dec 2023 10:30:17 +0000
On Sat, Dec 9, 2023 at 1:59 AM Thiago Macieira wrote:
>
> Right, because you used templates. But I don't think the standard would be
> that lax in defining the interface.


Okay then I think there are four options:
(1) Just allow my original code to give a compiler error
(2) Use a 'requires requires' constraint, but I don't think there's a way
of doing this that can take into account whether the argument is an Lvalue
or an Rvalue (although maybe this won't matter with a trivial?)
(3) Use a static_assert(false) with "if constexpr"
(4) The 'std::unaligned' type has compiler magic that makes it define all
of the non-const operators that are defined in 'T'.


Do you think Option No. 4 is the way to go?

Received on 2023-12-09 10:30:19