Question about auto ref

Jonathan M Davis jmdavisProg at gmx.com
Tue Mar 26 15:15:24 PDT 2013


On Tuesday, March 26, 2013 18:11:42 Jonathan M Davis wrote:
> On Tuesday, March 26, 2013 22:55:56 Minas Mina wrote:
> > Why is "const ref" not a good choice?
> 
> I really don't want to get into that again. There have been a number of
> discussions on it in the main newsgroup which you can search for, but Andrei
> considers it to be a major mistake of C++ that const& accepts rvalues, and
> he does not want to repeat that in D. So, just like ref, const ref in D
> accepts only lvalues (they're just const instead of mutable), and that's
> not going to change.

Another thing to consider is that because of how strict D's const is, our 
solution really should not require that the parameter be const. So, const ref 
wouldn't work for that unless it were agreed that ref could take rvalues as 
well, which would create a whole other set of problems.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list