Rvalue references - The resolution

Diggory diggsey at googlemail.com
Sat May 4 16:47:14 PDT 2013


On Saturday, 4 May 2013 at 23:44:27 UTC, Walter Bright wrote:
> On 5/4/2013 4:34 PM, Walter Bright wrote:
>>> And later down the road, maybe even in 2.064, ref will take 
>>> r-values
>>> making the new code error because of ambiguity between the two
>>> functions.
>>>
>>> Has code breakage ever been taken into account during this 
>>> dconf conversation?
>
> I see what you mean now. You mean how does an rvalue overload 
> if faced with T and ref T. Currently:
>
>   void foo(ref int i);
>   void foo(int i);
>
>   void main() {
>     int i;
>     foo(i);    // matches ref int
>     foo(1);    // matches int
>   }
>
> I don't think that should change with this proposal.

What about this:

void foo(ref int i);
void foo(ref const(int) i);

void main() {
     int i;
     foo(i);
     foo(1);
}

What do they match here?


More information about the Digitalmars-d mailing list