Discussion: Rvalue refs and a Move construtor for D
Suleyman
sahmi.soulaimane at gmail.com
Sun Sep 1 14:06:13 UTC 2019
On Sunday, 1 September 2019 at 08:59:08 UTC, Les De Ridder wrote:
> [...]
> Maybe a solution with a UDA is possible?
Possible.
> I'm not sure why there are three different ways to 'cast to an
> rvalue'?
> Is there a technical reason?
I'm just demonstrating the possibilities. Likely only one of them
will be picked.
> I also noticed you're casting lvalues to 'rvalues' and then
> binding them a `ref` param. Is that not an rvalue reference?
Yes but I would argue this is just a perk of rvalue ref and not
what the essence of it is.
You can do the same thing by assigning to a temporary then
passing it by ref. This all the compiler does here.
> Why can't we have generalised rvalue references instead?
What do you need if for? Rvalue ref comes with it's own
overloading and implicit conversion rules. Generalized rvalue ref
is not absolutely needed for move semantics. What else comes to
mind other than move semantics as a use case?
More information about the Digitalmars-d
mailing list