Binding rvalues to ref parameters redux

Alexibu alexibu at sunopti.com
Fri Mar 29 06:43:26 UTC 2019


On Thursday, 28 March 2019 at 23:40:45 UTC, Olivier FAURE wrote:
> On Thursday, 28 March 2019 at 20:11:26 UTC, Andrei Alexandrescu 
> wrote:
>> The nonassignable requirement is a major improvement, but 
>> won't catch all potential misuses. I don't know how to do 
>> better.
>
> You could be more strict and consider that any call of the form
>
>     applyDiscount(x.price)
>

The property disaster :

Struct X
{
  Currency price;
}

Evolves Into

Struct X
{
  Currency price() const {...}
  Void price(currency x){...}
}


Applydiscount(x.price);

Compiles to nop.

Is this revalue ref work an opportunity to have the compiler to 
try and call the setter with the result ?

Apologies phone post.




More information about the Digitalmars-d mailing list