C++ Logo

std-proposals

Advanced search

Re: [std-proposals] std::sizeof_minus_trailing_padding

From: Lénárd Szolnoki <cpp_at_[hidden]>
Date: Thu, 30 Nov 2023 21:14:11 +0000
On 30 November 2023 21:02:03 GMT, Thiago Macieira via Std-Proposals <std-proposals_at_[hidden]> wrote:
>On Thursday, 30 November 2023 11:17:50 CET Frederick Virchanza Gotham via Std-
>Proposals wrote:
>> This would allow us to write our own 'std::optional' that places the
>> boolean flag inside T's trailing padding.
>
>You can do that by inheriting from the type in question, if it is not final.

You can't inherit from an union though, which is needed for optional. You can do this with [[no_unique_address]].


>(In the IA-64 ABI; MSVC does not allow reusing the tail padding. In fact, it
>has known compiler bugs causing miscompilation there)
>

Received on 2023-11-30 21:14:17