DIP 36: Rvalue References

Zach the Mystic reachzach at gggggmail.com
Tue Apr 9 21:54:20 PDT 2013


On Wednesday, 10 April 2013 at 04:46:43 UTC, Zach the Mystic 
wrote:
> ref int bar(ref int x) { return x; }
>
> ref int foo(scope ref int x) {
>   int* y = new int;
>   *y = x;
>   return y;
> }
>
> ref int test() {
>   return foo(1); // allowed
>   return bar(1); // disallowed!
> }

When said 'bar(1)' was disallowed, I meant that it was considered 
local and not disallowed because it doesn't accept rvalue temps. 
Fix:

ref int test() {
   int y;
   return foo(y); // allowed
   return bar(y); // disallowed!
}


More information about the Digitalmars-d mailing list