ref auto getRange() return scope move struct ?

Newbie2019 newbie2019 at gmail.com
Fri Aug 16 12:23:01 UTC 2019


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 ?



More information about the Digitalmars-d-learn mailing list