rvalue references

Zach the Mystic reachzach at gggggmail.com
Thu Apr 25 16:58:33 PDT 2013


On Thursday, 25 April 2013 at 22:36:39 UTC, Jonathan M Davis 
wrote:
> Nowhere in here am I suggesting that ref itself be treated 
> differently, and
> nothing I'm describing really has anything to do with scope.
>
> - Jonathan M Davis

Okay, we're on the same page then. I was using 'scope' only as 
the '@newattr'. And I agree with your logic, and I understand the 
conflict with the existing templated 'auto ref's.

I also thought of the trick mentioned by Timon, where the 
compiler infers the need or lack thereof for the value/reference 
type in templates based on what things are done within the 
function body. But as you said, figuring out the rules for making 
the compiler smart enough to choose the right one seems like a 
hard task. If it forwards to another 'auto ref' template 
parameter, it needs to descend into that template, determine 
*its* type of parameter, and then assign the type of its own 
parameter accordingly.

It would be great if that proved to be a workable solution, not 
unlike the desirability of the compiler automatically determining 
if a class member function should be virtual or not. I don't know 
all of the cases which must be considered. Certainly if the 
parameter is assigned to, it must be 'ref', since the calling 
function will need the change. If the parameter is returned as 
'auto ref', I guess then it must certainly become 'auto ref' as 
it is currently implemented for templates. If it is passed to a 
'ref', then I would say it must be 'ref' itself. If it is passed 
to 'auto ref', it confuses me... nor do I know what other cases 
must be considered.


More information about the Digitalmars-d mailing list