On Thursday, 18 January 2018 at 16:14:18 UTC, ag0aep6g wrote:
On 01/18/2018 04:25 PM, Luís Marques wrote:
You need a reinterpret-style cast here to get an lvalue:
foo(* cast(int**) &ptr);
Right, that's what I wanted. Ugh, for some reason I was totally
confused about this :-)
writeln(*cast(int*) *ptr);
You're dereferencing twice here. Do it only once, after casting:
That was just a typo.
That way, `ptr` itself won't be updated by `foo`, of course.
But `ptr` isn't a `ref` parameter, so this only affects the
insides of `bar` anyway.
Yeah, it was a bad example.