const ref and rvalues

Martin Nowak dawg at dawgfoto.de
Wed Feb 15 21:38:51 PST 2012


On Thu, 16 Feb 2012 00:46:35 +0100, Trass3r <un at known.com> wrote:

> I posted this question several times already and no answer yet,
> why is allowing temporaries bind to ref const params bad again?

You'd want to pass temporaries by value, because then they can be  
constructed saving you a copy.
If you want a function that avoids copies for lvalues and rvalues then you  
need auto ref :(.
C++'s 'const &' is very easy to get wrong.


More information about the Digitalmars-d mailing list