C++ Logo


Advanced search

Subject: Re: [std-proposals] P1839 and the object representation of subobjects
From: language.lawyer_at_[hidden]
Date: 2020-07-21 16:53:52

On 22/07/2020 00:31, Giuseppe D'Angelo via Std-Proposals wrote:
> Il 21/07/20 17:01, Jason McKesson via Std-Proposals ha scritto:
>> We technically already have a way to do that: `std::launder`:
>> ```
>> auto byte_ptr = reinterpret_cast<byte *>(qoptr);
>> auto c1ptr = std::launder(reinterpret_cast<C1 *>(qoptr + off);
>> ```
>> If there is an object of type `C1` at the given address, then
>> `std::launder` will return a pointer to it. This is the purpose of
>> `launder`.
> I'm not 100% sure that P1839 would allow for the above reintepret_cast, though. And if it does, would std::launder still be necessary?

As I described in https://lists.isocpp.org/std-proposals/2020/07/1610.php, under P1839R2 std::launder would still be necessary.

STD-PROPOSALS list run by std-proposals-owner@lists.isocpp.org

Standard Proposals Archives on Google Groups