The liabilities of binding rvalues to ref

Dicebot m.strashun at gmail.com
Sun May 5 13:15:39 PDT 2013


On Sunday, 5 May 2013 at 16:21:37 UTC, deadalnix wrote:
> No, you won't be able to reach any of this anyway. Move 
> semantic is already cleanly implemented in D, so the C++ mess 
> is irrelevant here.

Agreed.

>>> - You want to avoid creating copies, when this isn't 
>>> necessary. In this case, this is a performance reason, and 
>>> binding to rvalue make sense.
>>
>> Not necessarily performance reason on its own, copy 
>> construction of given object may have an undesired side 
>> effects. Or it may be even some singleton'ish object.
>
> Having a singleton as a value type, and not marking the 
> postblit as @disable is asking for trouble in general, nothing 
> specific to the discussion here.

Yes, sure, but you will still use ref if you want ( don't ask why 
:) ) to use it as an argument to a function and not because of 
performance but because it is only option. I was objecting to 
stating that "avoiding copies" -> "performance reasons".


More information about the Digitalmars-d mailing list