ref auto getRange() return scope move struct ?

Newbie2019 newbie2019 at
Fri Aug 16 14:14:52 UTC 2019

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 be that what you're 
> trying to do here simply wouldn't work if you disallowed 
> moving, since DIP 1014 doesn't affect when the compiler does a 
> move. It just allows you to hook into when a move takes place 
> so that you can do stuff like adjust pointers, and presumably, 
> if you @disable the function that hooks into the move, moving 
> will then be disabled (though IIRC, that's not explicitly 
> called out in DIP 1014; it's just what would naturally fall out 
> from how @disable works).
> - Jonathan M Davis

Thanks for the very helpful explain, I will try find some work 
around to fix this.

One more question: If the struct has "@disable this() ;@disable 
this(this) ;",   and the instance is stored into other struct 
member or local|global vars,  it will never moved again?

More information about the Digitalmars-d-learn mailing list