DIP 1016--ref T accepts r-values--Community Review Round 1

Q. Schroll qs.il.paperinik at gmail.com
Fri Nov 9 18:10:48 UTC 2018


On Friday, 9 November 2018 at 02:25:08 UTC, Manu wrote:
> I think it's reasonable that `out` could reject rvalues.

I have a question about lifetime. Consider your example

   ref int gun(return ref int y);

The current state `ref` also means that the return value of `gun` 
has an address.

Using `gun` on an rvalue, it makes an invisible variable in the 
caller's scope.

Will

   int* p = &(gun(10));

compile and `p` be referencing the invisible variable?



More information about the Digitalmars-d mailing list