ref auto getRange() return scope move struct ?
Newbie2019
newbie2019 at gmail.com
Fri Aug 16 12:29:19 UTC 2019
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);
> }
> }
> Tree tree;
> auto range = tree.getRange();
> ------
>
> when I trace the issue, I find the address for TreeRange is
> moved. it TreeRange.__ctor the address is 0x7ffeefbfd168,
> but "auto range = tree.getRange();" address is 0x7ffeefbfd420
>
>
> How to prevent this struct move in this case ?
With dip1014 I can fix the internal pointer(but I guess It will
need maybe 1 years late to implement). Right now I just want
forbit the move action, is it doable ?
More information about the Digitalmars-d-learn
mailing list