C++ Logo

std-proposals

Advanced search

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

From: Breno Guimarães <brenorg_at_[hidden]>
Date: Thu, 24 Apr 2025 10:57:36 -0300
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

Em qui., 24 de abr. de 2025, 10:39, Jan Schultke via Std-Proposals <
std-proposals_at_[hidden]> escreveu:

> This proposal is still a solution looking for a problem. One huge
> issue worth addressing is that C++ already incentivizes you to make
> the default constructor and move constructor as simple as possible,
> and shift the cost elsewhere.
>
> Default constructors need to be kept simple because we do not have
> non-transient constexpr allocations. Default constructors can often be
> made constexpr and noexcept, unlike other constructors, and this
> enables the developer to avoid dynamic initialization, which reduces
> startup latency and sidesteps the dynamic initialization order fiasco.
>
> Anyone who's making expensive default constructors is already making
> questionable design decisions. Therefore, it makes no design sense for
> a moved-from constructor to be any cheaper.
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2025-04-24 13:57:50