On 25 April 2017 at 00:00, Steven Schveighoffer via Digitalmars-d <digitalmars-d@puremagic.com> wrote:
On 4/24/17 12:21 AM, Manu via Digitalmars-d wrote:

I wonder if this overload set could be made to work such that it is
certain that the non-ref overload is only called with rvalues; ie, given
this ambiguous call, ref is preferred for lvalues. rval can not call
ref, therefore must resolve to byval.

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.

auto ref just templates that. And in your case, it's actually clearer and cleaner not to use auto ref.

Not sure if this answers your question, or if it turns out to be a viable solution.

If you're going to pinch the guts of rvalue arguments, then this needs to be 100% reliable.
This needs to be aggressively unit-tested, and probably documented that this is the official pattern for rvalue construction/assignment operations.