DIP 1016--ref T accepts r-values--Final Review

Rubn where at is.this
Sat Nov 17 13:01:12 UTC 2018


     void lval_only(int x) @disable;
     void lval_only(ref int x);

     int x = 10;
     lval_only(x);  // ok: choose by-ref
     lval_only(10); // error: literal matches by-val, which is 
@disabled

For this what about if there are multiple parameters? How many 
overloads do you have to define to get this behavior?

     void lval_only(int x, int y) @disable;
     void lval_only(ref int x, ref int y);

     int x = 10;
     int y = 20;
     lval_only(x, y);  // ok: choose by-ref
     lval_only(10, 20); // error: literal matches by-val, which is 
@disabled
     lval_only(x, 20); // is this an error cause of @disable or 
not ?
     lval_only(10, y); // ditto


More information about the Digitalmars-d mailing list