C++ Logo


Advanced search

Subject: Re: [std-proposals] P1839 and the object representation of subobjects
From: Giuseppe D'Angelo (giuseppe.dangelo_at_[hidden])
Date: 2020-07-21 16:31:02

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?

Thanks for the insight,

Giuseppe D'Angelo | giuseppe.dangelo_at_[hidden] | Senior Software Engineer
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com
KDAB - The Qt, C++ and OpenGL Experts

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

Standard Proposals Archives on Google Groups