C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Replace an object -- but retain old object if new object fails to construct

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Wed, 29 Oct 2025 15:11:24 +0000
On Wednesday, October 29, 2025, Frederick Virchanza Gotham wrote:

>
>
> So maybe a better term would be "custom_written" or "custom_composed", or
> better yet: "custom_implemented".
>
> So we would say that std::string, in the short string optimization mode,
> has a custom-implemented relocation algorithm:
>
> std::has_custom_implemented_relocator
>
> And we could then reserve the meaning of "is_trivially_reloctable" to mean
> that you can do a memcpy without editing any bits.
>



Sorry I should be more clear.

I'm saying that there are four different classifications when it comes to a
type's relocatability:

(Type 1) Cannot be relocated
(Type 2) Can be relocated by a simple memcpy
(Type 3) Can be relocated by an algorithm built into the compiler
(Type 4) Can be relocated by a custom-implemented relocator algorithm
provided by the author of the class

So, on arm64e when you relocate a simple polymorphic object, you get Type
3. (Whereas on every other compiler it's only Type 2).

Type 4 would be the likes of std::string in short-string optimisation mode.

Type 1 would be std::mutex.

Received on 2025-10-29 15:11:26