Move construction from !is(T == typeof(this))

Manu via Digitalmars-d digitalmars-d at puremagic.com
Mon Apr 24 08:19:29 PDT 2017


On 25 April 2017 at 00:00, Steven Schveighoffer via Digitalmars-d <
digitalmars-d at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20170425/13419a2b/attachment-0001.html>


More information about the Digitalmars-d mailing list