R-values and const ref

Steven Schveighoffer schveiguy at yahoo.com
Thu Sep 9 08:26:26 PDT 2010


On Thu, 09 Sep 2010 11:24:14 -0400, Eldar Insafutdinov  
<e.insafutdinov at gmail.com> wrote:

> I agree that auto ref may be a better option here, but I still see no  
> reason to
> disallow it. It is a performance issue, not a safety one. And as you  
> said this
> only works for templates, virtual functions are out of the game here.
>
> PS. opEquals issue is very annoying, indeed.

Yes, I forgot that you are allowed to overload via ref.  That would make  
sense for virtual functions.

The problem with allowing const ref rvalues is then you are not *able* to  
make a better performing function, because rvalues match against const ref  
as well as the non-ref version.

-Steve


More information about the Digitalmars-d mailing list