Parameter forwarding

Tejas notrealemail at gmail.com
Fri Oct 15 17:22:52 UTC 2021


On Friday, 15 October 2021 at 06:52:41 UTC, Kostiantyn Tokar 
wrote:
> On Thursday, 14 October 2021 at 17:53:57 UTC, Tejas wrote:
>>
>> Maybe DIP 1040 will automatically solve that?
>>
>>>last use of objects that is a copy gets elided into a move
>>
>> That is what it states, so maybe this one time, the problem 
>> will go away just by waiting?
>
> It would be great, but still, if I understand correctly, it is 
> not perfect solution for lvalue arguments. Consider, e.g., 
> `Tuple` construction from an lvalue. With this DIP and current 
> state of constructor it will be 1 copy (from argument to 
> constructor's parameter) and 1 blit (from parameter to the 
> field). With `auto ref` and forwarding it would be 1 copy from 
> parameter to the field and no blits. Forwarding saves one blit 
> per indirection, i.e., for `tuple` it would be 2 blits vs. 0.

Yeah blitting as a concept will go away from D(will only stay for 
backwards-compatibility)

Copy constructors already made blits obselete, move constructors 
will remove the need for post-blits and finish the job and the 
second case that you talked about will become the default



More information about the Digitalmars-d-learn mailing list