<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 25 April 2017 at 00:00, Steven Schveighoffer via Digitalmars-d <span dir="ltr"><<a href="mailto:digitalmars-d@puremagic.com" target="_blank">digitalmars-d@puremagic.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 4/24/17 12:21 AM, Manu via Digitalmars-d wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I wonder if this overload set could be made to work such that it is<br>
certain that the non-ref overload is only called with rvalues; ie, given<br>
this ambiguous call, ref is preferred for lvalues. rval can not call<br>
ref, therefore must resolve to byval.<br>
</blockquote>
<br></span>
AFAIK, if you have an overload that varies solely on ref, then rvalues go to the non-ref and lvalues go to the ref. If this is not the case, it's *intended* to be the case, and should be filed as a bug.<br>
<br>
auto ref just templates that. And in your case, it's actually clearer and cleaner not to use auto ref.<br>
<br>
Not sure if this answers your question, or if it turns out to be a viable solution.<br></blockquote><div><br></div><div>If you're going to pinch the guts of rvalue arguments, then this needs to be 100% reliable.</div><div>This needs to be aggressively unit-tested, and probably documented that this is the official pattern for rvalue construction/assignment operations.</div></div></div></div>