<div dir="ltr"><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, 4 Oct 2024 at 06:56, 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 17:47, Walter Bright wrote:<br>
> <br>
> __rvalue() is not a move, it just guides the overload resolution to the <br>
> move constructor/assignment. It's a hint.<br>
<br>
It has to be a move though. An rvalue is owned, an lvalue is not. <br>
Whenever an lvalue goes into an rvalue, it is either copy or move.<br>
<br>
If `__rvalue` is just some sort of ad-hoc type-punning operation <br>
exclusively for overload resolution, it will often copy the argument, <br>
unless your intention is to force it to be consumed by a function that <br>
is implicitly `@move` (such as a move constructor or a move assignment).<br></blockquote><div><br></div><div>Yes, exactly... __rvalue() must be SOME KIND of move; it is explicitly taking ownership away from the owner, and handing it to some new owner.</div><div>The thing about __rvalue() is that you will hide it inside some function, like `T move(ref T t) => __rvalue(t)`</div><div>That encapsulates the ownership transfer, and separates the visibility of the ownership transfer from the calling scope where that information is needed.</div><div>Maybe you should reserve the name `move` and make it an error for a user to produce any declaration with that name? That might avoid your surprise overload issue?<br></div></div></div>