Copy a struct and its context

Basile B. via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Sep 13 13:05:23 PDT 2016


On Tuesday, 13 September 2016 at 01:32:19 UTC, Steven 
Schveighoffer wrote:
> On 9/12/16 4:11 PM, Ali Çehreli wrote:
>> On 09/10/2016 10:44 PM, Yuxuan Shui wrote:
>>> I recently noticed nested struct capture its context by 
>>> reference
>>> (which, BTW, is not mentioned at all here:
>>> https://dlang.org/spec/struct.html#nested).
>
> He wants to deep-copy the struct, meaning copy the context 
> pointer data. Meaning if you change 'i' in s, then s_copy's foo 
> still returns 42.
>
> I don't think it is or should be doable.
>
> -Steve

with stack stomp no way that any hack could work, if any.


More information about the Digitalmars-d-learn mailing list