R-values and const ref

Steven Schveighoffer schveiguy at yahoo.com
Thu Sep 9 10:12:22 PDT 2010


On Thu, 09 Sep 2010 13:03:17 -0400, Andrei Alexandrescu  
<SeeWebsiteForEmail at erdani.org> wrote:

> On 9/9/10 6:32 CDT, Steven Schveighoffer wrote:
>> On Thu, 09 Sep 2010 06:08:14 -0400, Eldar Insafutdinov
>> <e.insafutdinov at gmail.com> wrote:
>>
>>> A while back dmd stopped allowing rvalues as ref function arguments. I
>>> entirely understand why it was done, but the same restriction applies
>>> to the
>>> ref const function parameters. This causes a lot of pain and at the
>>> moment
>>> makes me use pass-by-value parameters(most notably when using
>>> structs). C++
>>> doesn't have any problem with const ref and rvalues. Can we please
>>> restore
>>> this behavior for const ref?
>>
>> auto ref is supposed to handle that. However, I think it only works on
>> templates.
>
> Indeed, auto ref must work with non-templates.

Hm... how is that possible?  The generated code must surely be different,  
so it is in fact a template, even if it's not syntaxed as one.

-Steve


More information about the Digitalmars-d mailing list