The liabilities of binding rvalues to ref

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Thu May 9 18:54:27 PDT 2013


On 5/9/13 6:09 PM, Jonathan M Davis wrote:
> On Friday, May 10, 2013 07:35:36 Manu wrote:
>> I don't think this is entirely true, auto ref is a template concept, that
>> is, "automatic ref-ness", it selects the ref-ness of the argument
>> automatically, at compile time, just like auto applied everywhere else
>> (selects a type for instance, at compile time). This concept doesn't make
>> any sense applied to a non-template. It *IS* a ref as specified by the
>> programmer, there's nothing 'automatic' about it.
>
> I don't buy this at all. The entire point of auto ref on parameters was to say
> that you wanted to accept both rvalues and lvalues efficiently. The fact that
> the template implementation happened to forward refness as a result was a
> happy accident. auto ref is already described in TDPL, and it has nothing to
> do with templates there. Using auto ref on non-templated functions would be
> completely in line with what TDPL describes and would implement another
> feature from TDPL that we're currently missing.

Exactly. I'll add that just saying "auto is a template concept" is 
really devoid of information. It really is meaningless because "concept" 
is so broad a word. One may as well say "class is an abstraction notion" 
or any of a large variety of similar constructs.

Andrei


More information about the Digitalmars-d mailing list