Rvalue references - The resolution

Timon Gehr timon.gehr at gmx.ch
Sat May 4 16:54:05 PDT 2013


On 05/05/2013 01:47 AM, Diggory wrote:
> 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?

Both match the first overload because that is an exact match whereas the 
second overload is only a match with conversion to const.


More information about the Digitalmars-d mailing list