My thoughts & tries with rvalue references

Namespace rswhite4 at googlemail.com
Sat Mar 30 07:37:09 PDT 2013


> No I highly appreciate it, that you are trying to solve the 
> problem. The current state of the language on this is annoying 
> and it needs to be fixed.
>
> I personally would like &A the question is if this is the 
> "D-Way". Maybe we should add a new keyword like "vref" for 
> "value reference".
>
> Kind Regards
> Benjamin Thaut

That's nice to hear. I was afraid I would be too intrusive on 
this.
And I've finally did it: A& works now. It was a bit tricky, but 
now it works nicely. Here a quick example:

void bar1(A& a) { } // OK
void bar2(A&* a) { } // Error: '&' can not be used in combination 
with '*'
void bar3(A*& a) { } // Error: '&' can not be used in combination 
with '*'
void bar4(const A& a) { } // OK
void bar5(ref A& a) { } // Error: conflicting storage class '&' 
and ref

and for templates:

void bar(T)(T& t) {
	writeln(t);
}

Thoughts?


More information about the Digitalmars-d mailing list