rvalue references

Namespace rswhite4 at googlemail.com
Sat Apr 27 04:11:54 PDT 2013


You often say that 'auto ref' can not work for non-templates.
Why not really?
Because the resulting code bloat is not bearable, or because it 
is technically not possible?

I ask because actually this would be the best performing solution.
----
void foo(auto ref const A a) { }
//is converted to:
void foo(ref const A a) { }
//and
void foo(const A a) {
     return foo(a); //call ref version
}
----

And it work like:
----
A a = A(42);
foo(a); // call foo(ref const A a)
foo(A(23)); // call foo(const A a)
----
So no postblit is called and there is no temporary on the caller 
side.


Also I would like to see an answer of my overlooked question 
(just out of curiosity): 
http://forum.dlang.org/thread/kl4v8r$tkc$1@digitalmars.com?page=7#post-kyicmdsriwnxqiuzkaho:40forum.dlang.org


More information about the Digitalmars-d mailing list