DIP 36: Rvalue References

Timon Gehr timon.gehr at gmx.ch
Wed Apr 24 06:18:07 PDT 2013


On 04/24/2013 02:41 AM, kenji hara wrote:
> ...
>
> 1. "parameterized-ref" is already there with the syntax `auto ref`.
> Removing it introduces breaking language change.
>
> 2. If we remove "parameterized-ref" from D, we will lose the ability to
> write certain kind of template functions. For example:
>
>      auto ref forward(T)(auto ref T arg) { return arg; }
>
> The parameter `arg` is instantiated with both ref/non-ref, and forward
> `function` returns also both ref/non-ref value. In such case, you cannot
> replace "parameterized-ref" to "rvalue-ref".
>
> These are why DIP36 is necessary. Repeatedly, I think removing current
> `auto ref` is not good.
>...

We could specify that if there is no influence (to be made more precise) 
of the actual ref-ness for the function semantics, the second copy is 
elided. It is then illegal for non-templated functions to require 
multiple copies.

This would merge the two features under the name auto ref.


More information about the Digitalmars-d mailing list