Parameter forwarding
Kostiantyn Tokar
tokarkonstantyn at yandex.ua
Fri Oct 15 06:52:41 UTC 2021
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.
More information about the Digitalmars-d-learn
mailing list