Why do struct literals count as lvalues?
Trass3r
un at known.com
Fri Aug 19 09:13:18 PDT 2011
Am 19.08.2011, 14:50 Uhr, schrieb Timon Gehr <timon.gehr at gmx.ch>:
> void foo(ref S);
> ...
> foo(S(...));
>
> is equivalent to one explicitly declaring the temporary:
>
> {auto __temp=S(...); foo(__temp);}
>
> The difference is that the first is more pleasant to write. If
> temporaries would become rvalues everyone would always have to write the
> second form manually. So imho it is just a syntax sugar issue.
>
> I'd actually argue that ref-passing should work for arbitrary function
> results too.
+1, but const should be required.
More information about the Digitalmars-d
mailing list