Discussion: Rvalue refs and a Move construtor for D

Manu turkeyman at gmail.com
Thu Aug 29 04:22:55 UTC 2019


On Wed, Aug 28, 2019 at 5:15 PM Mike Franklin via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
>
> On Wednesday, 28 August 2019 at 23:32:01 UTC, Suleyman wrote:
>
> > The move constructor and the move assignment operator can be
> > made in D with or without rvalue refs. Here a short comparison
> > of both scenarios.
> >
> > ## With rvalue ref
> >
> > Example:
> > ```
> > struct S
> > {
> >     this(@rvalue ref S) { /* move constructor */ }
> >     auto opAssign(@rvalue ref S) { /* move op assign */ }
> > }
> > ```
> >
> > * Pros:
> >  - seems natural: doesn't smell like compiler magic (but it
> > still is compiler magic, at least until D adopts implicit
> > constructors)
>
> There are some of us that would really like implicit constructors
> (done right; not like C++) for other use cases. How would
> implicit constructors help this situation, and should it be
> included as part of this proposal?

@implicit constructors should have been part of the copy-ctor
proposal, which I argued at the time... but it wasn't so it's
effectively an unrelated DIP now.


More information about the Digitalmars-d mailing list