Re: ref auto getRange() return scope move struct ?

2019-08-16 Thread Newbie2019 via Digitalmars-d-learn
On Friday, 16 August 2019 at 16:22:27 UTC, Jonathan M Davis wrote: [...] Thanks very much again, very helpful explain. I use pass by ref scope instead "return TreeRange.__ctor();" to workround this issue.

Re: ref auto getRange() return scope move struct ?

2019-08-16 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, August 16, 2019 8:14:52 AM MDT Newbie2019 via Digitalmars-d-learn wrote: > On Friday, 16 August 2019 at 13:51:49 UTC, Jonathan M Davis wrote: > > It is not possible to prevent moving in D as things currently > > stand. DIP 1014 will need to be implemented to either hook into > > moves

Re: ref auto getRange() return scope move struct ?

2019-08-16 Thread Newbie2019 via Digitalmars-d-learn
On Friday, 16 August 2019 at 13:51:49 UTC, Jonathan M Davis wrote: It is not possible to prevent moving in D as things currently stand. DIP 1014 will need to be implemented to either hook into moves or to prevent them. However, once DIP 1014 has been implemented, I would expect the result to

Re: ref auto getRange() return scope move struct ?

2019-08-16 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, August 16, 2019 6:29:19 AM MDT Newbie2019 via Digitalmars-d-learn wrote: > On Friday, 16 August 2019 at 12:23:01 UTC, Newbie2019 wrote: > > I has this simple function has some memory bugs: > > > > --- > > struct TreeRange { > > > > @disable this() ; > > @disable this(this)

Re: ref auto getRange() return scope move struct ?

2019-08-16 Thread Newbie2019 via Digitalmars-d-learn
On Friday, 16 August 2019 at 12:23:01 UTC, Newbie2019 wrote: I has this simple function has some memory bugs: --- struct TreeRange { @disable this() ; @disable this(this) ; } struct Tree { ref auto getRange() return scope { return TreeRange!T(_root);

ref auto getRange() return scope move struct ?

2019-08-16 Thread Newbie2019 via Digitalmars-d-learn
I has this simple function has some memory bugs: --- struct TreeRange { @disable this() ; @disable this(this) ; } struct Tree { ref auto getRange() return scope { return TreeRange!T(_root); } } Tree tree; auto range = tree.getRange(); --