www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Copy only frame pointer between objects of nested struct

I asked in D.learn, but didn't get a satisfactory answer. I think 
this may be unachievable in the current language.

Consider:

auto foo(T)(T a) {
	T b;  // Error: cannot access frame pointer of main.X
	b.data[] = 1;
	return b;
}

void main() {
	struct X {
		this(int) {}
		int[4096] data;
	}
	foo(X());	
}

Note the error is because you cannot construct the main.X object
without a frame pointer.

You could do `T b = a` here to get a's frame pointer, but it
would also copy all of a's data, which is expensive and
unnecessary.

Is there a way to only copy a's frame pointer into b?

(Note: this is just an illustrative example, real problem here:
https://issues.dlang.org/show_bug.cgi?id=13935)
Jan 09 2015