lvalue method

Steven Schveighoffer schveiguy at yahoo.com
Fri Oct 8 07:10:19 PDT 2010


On Fri, 08 Oct 2010 09:51:59 -0400, Simen kjaeraas  
<simen.kjaras at gmail.com> wrote:

> Steven Schveighoffer <schveiguy at yahoo.com> wrote:
>
>> The correct way is to use auto ref as the parameter:
>>
>> struct vec4
>> {
>>     ...
>>     vec4 Normalize(auto ref const(vec4) param) {...}
>> }
>>
>> But AFAIK, this doesn't really work.
>
> It doesn't, no. I'm not even sure it's scheduled for inclusion.

Andrei, I thought this was planned?

> Also, with bugzilla #4843, overloading ref/non-ref for structs don't
> work, so the only current solution is to not use ref.

Bummer.  At least rvalues will be as fast as possible, and it will work as  
a temporary solution.

FWIW, I don't consider duplicating a function to be a good solution, we  
can do better.

But don't try doing opEquals without ref const, because the compiler won't  
allow it :)

-Steve


More information about the Digitalmars-d-learn mailing list