Date: Wed, 22 Jul 2020 00:53:52 +0300
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.
> 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.
Received on 2020-07-21 16:57:13