<div dir="ltr"><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 3 Oct 2024 at 10:06, Timon Gehr via Digitalmars-d <<a href="mailto:digitalmars-d@puremagic.com">digitalmars-d@puremagic.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 10/3/24 01:07, Manu wrote:<br>
> On Thu, 3 Oct 2024 at 03:21, Walter Bright via Digitalmars-d <br>
> <<a href="mailto:digitalmars-d@puremagic.com" target="_blank">digitalmars-d@puremagic.com</a> <mailto:<a href="mailto:digitalmars-d@puremagic.com" target="_blank">digitalmars-d@puremagic.com</a>>> wrote:<br>
> <br>
>     On 10/1/2024 1:15 PM, Timon Gehr wrote:<br>
>      > I guess the new implementation you have in mind is something like<br>
>     the following?<br>
>      ><br>
>      > ```d<br>
>      > auto move(T)(ref T arg)=>__rvalue(arg);<br>
>      > ```<br>
> <br>
>     Not exactly. __rvalue would also convert an rvalue to an rvalue.<br>
> <br>
> <br>
> -preview=rvaluerefparams addresses this; it allows an rvalue to be <br>
> supplied to the lvalue there. It's actually an essential mechanic to <br>
> this whole thing, because it will allow the appropriate selection of <br>
> copy/move overloads where a type may define either one, or both. If a <br>
> copy and/or move constructor exists, it needs to select the proper one, <br>
> and the -preview handles that properly as is.<br>
<br>
`-preview=rvaluerefparam` allows you to treat an rvalue as an lvalue <br>
implicitly in some contexts.<br>
<br>
`__rvalue` allows you to treat an lvalue explicitly as an rvalue, so it <br>
will be moved.<br>
<br>
I fail to see how those are related.<br></blockquote><div><br></div><div>__rvalue() needs to be callable with an lvalue or an rvalue.</div><div>That's the only specific interaction on this matter, but beyond that with respect to move semantics in practice; in your application, you will encounter types with copy and/or move constructors/assign operators, general overloads, etc... you need to be able to pass the values that you have and your code needs to work without friction.</div><div>If there is a copy constructor and no move constructor for instance (very common situation) and you pass an rvalue, the code needs to compile. Later if you add a move constructor, it will automatically select that as the appropriate choice.<br></div></div></div>