Date: Thu, 30 Oct 2025 12:05:25 -0400
On Thu, Oct 30, 2025 at 11:15 AM Giuseppe D'Angelo via Std-Proposals <
std-proposals_at_[hidden]> wrote:
> Il 30/10/25 15:27, Thiago Macieira via Std-Proposals ha scritto:
> > I'll accept a replacement function if realloc() can't be fixed. But
> there needs
> > to be something that resizes an allocated memory block for trivially-
> > relocatable objects and has a good chance of not moving the memory block
> > (resize-in-place). Was that added by P2786?
>
> No. P2786 / trivial relocation as per the current working draft doesn't
> grant any special features to realloc(). std::trivially_relocate is the
> only entry point for trivial relocation.
>
> From my understanding, P3858 (likely C++29 material at this point)
> wants to correct this by introducing a lower-level primitive than
> std::trivially_relocate.
>
> The idea is that you will be able to move object representations in
> memory using *any* facility you like (including realloc()), but then you
> need to call std::restart_lifetime<T>() to tell the abstract machine¹
> that there are objects of type T at the destination whose lifetime needs
> to be started.
>
> I'm also 99% sure that P3858 does not solve the problem of detecting
> bitwise trivial relocability (detection that we need for things like
> QVariant), but that's a separate can of worms...
>
All correct.
I'm astonished that you and Qt are not making any noise about this.
–Arthur
std-proposals_at_[hidden]> wrote:
> Il 30/10/25 15:27, Thiago Macieira via Std-Proposals ha scritto:
> > I'll accept a replacement function if realloc() can't be fixed. But
> there needs
> > to be something that resizes an allocated memory block for trivially-
> > relocatable objects and has a good chance of not moving the memory block
> > (resize-in-place). Was that added by P2786?
>
> No. P2786 / trivial relocation as per the current working draft doesn't
> grant any special features to realloc(). std::trivially_relocate is the
> only entry point for trivial relocation.
>
> From my understanding, P3858 (likely C++29 material at this point)
> wants to correct this by introducing a lower-level primitive than
> std::trivially_relocate.
>
> The idea is that you will be able to move object representations in
> memory using *any* facility you like (including realloc()), but then you
> need to call std::restart_lifetime<T>() to tell the abstract machine¹
> that there are objects of type T at the destination whose lifetime needs
> to be started.
>
> I'm also 99% sure that P3858 does not solve the problem of detecting
> bitwise trivial relocability (detection that we need for things like
> QVariant), but that's a separate can of worms...
>
All correct.
I'm astonished that you and Qt are not making any noise about this.
–Arthur
Received on 2025-10-30 16:05:40
