cast ref pointer
Luís Marques
luis at luismarques.eu
Thu Jan 18 16:32:20 UTC 2018
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.
More information about the Digitalmars-d-learn
mailing list