Move Constructor Syntax
Manu
turkeyman at gmail.com
Sat Oct 12 08:23:02 UTC 2024
On Sat, 12 Oct 2024, 11:00 Walter Bright via Digitalmars-d, <
digitalmars-d at puremagic.com> wrote:
> On 10/11/2024 12:06 AM, Manu wrote:
> > But, I think you actually missed my point here; I provided a ref and
> non-ref
> > overload for Other... how do I move-construct from some OTHER type?
>
> I'm not sure moving a T to an S even makes sense.
>
Absolutely does, and it's essential.
Super common and super useful.
But writing a function to convert an S to a T, and then set the S to its
> default
> initializer, should work.
>
Both perspectives are valid, the distinction might regard whether S knows
that T exists or vice versa. In my experience, the arrangement where you
construct something from some 'upstream' thing is the far more common case.
Or, it might just work out that an API is much more ergonomic one way or
the other.
It doesn't matter though, your rvalue design handles this naturally... it
shouldn't require a single special line of code in the compiler... that's
one of the things that's so compelling about it!
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20241012/39b032b3/attachment.htm>
More information about the Digitalmars-d
mailing list