My thoughts & tries with rvalue references

Dicebot m.strashun at gmail.com
Fri Apr 5 02:02:32 PDT 2013


On Friday, 5 April 2013 at 08:57:35 UTC, Namespace wrote:
>> How so? It does not break anything, as all "const scope" cases 
>> can be processed with "const scope ref", in fact, compiler 
>> should be allowed to degrade first to latter. Regarding 
>> meaning - if "scope ref" means permissive rvalues (mutable 
>> ones), then "const scope ref" means closer match for C++ 
>> "const &" - constant references that can't escape scope.
> What I meant was simply, that users which are using already "in 
> ref" would get then the error: "redundant storage class: ref" 
> because 'in' would contains 'ref' already. That's the whole 
> reason of my rejection. ;)

I am surprised to hear that redundant storage classes are 
considered an error by dmd :) Makes no sense for me, typical 
"generic code gen" use case story.

>> I actually have an impression you do really want exactly 
>> "const scope ref" considering frequent references to C++.
> No, I like to get 'scope ref' just as much as 'in ref' / 'scope 
> const ref'. Mutable rvalue references are absolutely useful.
> How did you get the idea?

Sorry then, I have misunderstood you then. I do want both "scope 
ref" and "const scope ref" too, but I was thinking that simple 
easy-to-use shortcut (in) should match most idiomatic and safe 
use case, and that should be "scope const ref". With an 
additional benefit of being able to replace values with refs 
transparently due to storage class/qualifier restrictions.

I don't have strong opinion here, it is just an idea that came to 
my mind today and felt tempting ;)


More information about the Digitalmars-d mailing list