Nasty corner case behaviour

Suleyman sahmi.soulaimane at gmail.com
Sat Apr 20 00:25:44 UTC 2019


On Friday, 19 April 2019 at 23:42:53 UTC, Meta wrote:
> I find this one a bit confusing. Shouldn't the struct be moved 
> to the heap when the compiler detects that it's being closed 
> over?

It does. the `this` parameter in the following function is copied 
to a heap closure space.

	auto method() {
  		return [ 1 ].filter!(e => this.flag);
  	}

But `this` is a reference so the pointer is copied instead of the 
value.



More information about the Digitalmars-d mailing list