does 'auto ref T' copy or not if passed rvalue
Andrej Mitrovic
andrej.mitrovich at gmail.com
Mon Dec 17 09:51:35 PST 2012
On 12/17/12, Dan <dbdavidson at yahoo.com> wrote:
> Is it an optimization?
I think it is. You can get rid of auto ref and you'll see it still
doesn't copy for the second case, e.g. change signature to:
void foo(S t);
And only this call copies:
foo(s);
This one doesn't copy:
foo(S(['x', 'y', 'z']));
The optimization makes sense since this object doesn't exist outside
the foo function.
Btw, you might want to use `char[] c;`, not `char c[];` since that
syntax will eventually be deprecated.
More information about the Digitalmars-d-learn
mailing list