const ref and rvalues
dac at nospam.com
Thu Feb 16 02:07:38 PST 2012
On 16/02/12 06:38, Martin Nowak wrote:
> 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 :(.
Yes but that doesn't work for const.
> C++'s 'const &' is very easy to get wrong.
Yes, but D still hasn't got it right.
As far as I can tell, "const ref" in a parameter list is ALWAYS a bug.
More information about the Digitalmars-d