On Thu, 03 Jun 2010 09:09:39 -0400, Kagamin <s...@here.lot> wrote:

Steven Schveighoffer Wrote:

However, it surprisingly is less optimal for rvalues to pass by ref.

So what? It just must work. Efficiency of a particular operation doesn't mean efficiency of a program: it can use lvalues most of time.

Using lvalues is just as inefficient as passing temporaries via ref. The issue is that you can get *better* performance by passing temporaries by value than you can get by passing lvalues by value or by reference. Without something like auto ref, you put achieving the highest performance at odds with usability.


D's solution is to use auto ref, but I think your attempts to use it show
that it doesn't work.  You should file a bug with your program 3.

auto ref works only for return values, implementing it for parameters means combinatorial bloat.

At this point, the problem is that there is *nothing* that works for both rvalues and lvalues. auto ref would be something that works, even if it meant duplicating generated code.

I personally don't see a huge problem with allowing temporaries to be passed via ref const. It could be a tradeoff between low performance vs. smaller footprint.

But Andrei feels very strongly that passing temporaries via const ref is a complete mess in C++, so you'll have to convince him.

-Steve

Reply via email to