Discussion: Rvalue refs and a Move construtor for D
Suleyman
sahmi.soulaimane at gmail.com
Sun Sep 8 18:49:51 UTC 2019
On Sunday, 8 September 2019 at 03:21:06 UTC, Manu wrote:
> Actually, why doesn't it naturally work with pointers?
> The same way `scope` applied to pointers or ref's or anything
> with
> references, shouldn't `@rvalue` have the same attribution
> semantics as
> `scope` for instance?
> I guess you're right; if it didn't naturally apply to pointers
> the
> same way `scope` does, it would be a weird kind of edge case.
> The application of the attribute should behave the same as
> `scope`.
I didn't mean it should be like scope. I meant it should be like
const an shared. For example the address of an rvalue ref is
pointer to an rvalue type `is(typeof(&arg) == rvalue(S)*)` this
way rvalueness is preserved when the adress is taken, thus you
can have something like `rvalue(S)***`. Dereferencing such such
pointers returns an rvalue ref thus automatically calls the move
constructor instead of the copy constructor.
More information about the Digitalmars-d
mailing list