[phobos] Issues with dcollections

Andrei Alexandrescu andrei at erdani.com
Mon Apr 26 14:13:53 PDT 2010


On 04/26/2010 03:56 PM, Steve Schveighoffer wrote:
> Sorry, but that's not a reason.  Can you point to specifics?  The
> only reason I can think of is that C++ const is not transitive...

It's a long story. Binding rvalues to const references was a bad move 
that rvalue references are still trying to fix.

In D, we have enough of a hole by allowing rvalue objects to bind to 
ref. Let's not widen that.

Fundamentally, a ref originates from an lvalue with an identity and a 
place in memory. An rvalue is not quite all that. That's in short why 
binding an rvalue to a reference is fraught with peril: you are 
weakening what ref really means.

> How does auto ref solve the problem?

auto ref hits the spot. It means "I'm ok whether this data is an rvalue 
or an lvalue".


Andrei


More information about the phobos mailing list