rvalues -> ref (yup... again!)

Atila Neves atila.neves at gmail.com
Tue Mar 27 15:50:37 UTC 2018


On Tuesday, 27 March 2018 at 02:41:12 UTC, Manu wrote:

> He's trying to say that C++ introduced rvalue references 
> because normal references weren't able to allow for move 
> semantics to exist. It's a red-herring. D already has move 
> semantics, they work well, and they're not on trial here.
>
> In C++'s case, it's not that references were deficient at being
> references that C++ needed rval-references, it's that 
> references were
> deficient at being move-able.

There were deficient at being moveable because temporaries can 
bind to const T&.

> That is not a problem that exists in D.

Because temporaries can't bind to ref const(T).

> It's fine for references to
> just be references in D. We're not struggling to make references
> move-able in D, that's not a thing, we already have move 
> semantics.
> Any extension of this conversation about references into C++
> rvalue-references (T&&) and or move-semantics are red-herrings.
> There's no such problem in D that needs to be resolved, and the
> existing solution is excellent.

If I'm reading you correctly (which I might not), you seem to be 
saying that there's a way forward in which:

1) D's move semantics aren't affected
2) No rvalue references are introduced
3) Temporaries can bind to ref const(T)

I'd love to know what that would look like.

Atila



More information about the Digitalmars-d mailing list