Const ref and rvalues again...

martin kinke at libero.it
Tue Nov 6 18:45:14 PST 2012


On Tuesday, 6 November 2012 at 23:37:25 UTC, martin wrote:
> 1) The previously described auto-templates (identical 'auto 
> ref' semantics), where a function with 'auto ref' parameters is 
> treated as implicit template. This may lead to code-bloating 
> (for larger functions) and/or higher performance for rvalue 
> arguments (rvalues passed to value arguments are moved, not 
> copied; we therefore gain nothing by passing a reference, but 
> incur a slight performance hit due to pointer indirection 
> instead of accessing directly the rvalue on the stack). OR
> 2) Simple under-the-hood temporary lvalue declaration by the 
> compiler (for rvalues passed to 'const ref' parameters) - that 
> would be a handy implementation of the first workaround.

Please discard option 1, I'm afraid it creates too much confusion 
and was not well thought through. The objective was to expand 
'auto ref T' to either 'in ref T' for lvalues or 'in T' for 
rvalues (i.e., only for const parameters!), but then its caption 
would be horribly misleading (and something like 'in auto ref' 
would be way too ambiguous).



More information about the Digitalmars-d mailing list