C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Idea: moved_from<T>() for Efficient Moved-From State Construction

From: Andrey Semashev <andrey.semashev_at_[hidden]>
Date: Thu, 24 Apr 2025 17:48:53 +0300
On 24 Apr 2025 17:21, Jonathan Wakely via Std-Proposals wrote:
> On Thu, 24 Apr 2025 at 14:57, Breno GuimarĂ£es via Std-Proposals
> <std-proposals_at_[hidden]> wrote:
>>
>> If the author of the class needs to implement the specialization for moved_from<T>, they might very well implement a constructor that takes a tag indicating it's a type for overwrite.
>> I don't get why this facility would help in any way
>
> Exactly. If you are able to modify the class to support a possible
> change to the language which might happen one day, you could modify
> the class today to not require such a change to the language. If you
> can't add such a constructor, you wouldn't be able to take advantage
> of a hypothetical language change either.

The value of the proposal would be standardizing the protocol for
creating moved-from objects. This would be useful for generic
programming, where the user would be able to create moved-from objects
from any library that supports the protocol (whether it is the standard
library or not).

Received on 2025-04-24 14:48:56