copying a struct containing a struct

eskimo jfanatiker at gmx.at
Fri Nov 16 15:06:27 PST 2012


> "opAssign(TTest other)"
Thanks for highlighting this, now it is at least clear what happens. 

> --------
> The fact that "opAssign called for: " is not printed is, AFAIK, a 
> HUGE and old standing bug: The fields of the struct are bit 
> copied (!)

I now re-read the section in TDPL about move semantics:
	First off, D objects must be relocatable, ...

Well now I know why I got a problem, mine are not (not in the example
but in https://github.com/eskimor/phobos/blob/new_signal/std/signals.d
).

I register a delegate to a struct method in the postblit constructor, so
it is not relocatable, that is why things break so horrible. I
deregister the delegate in the destructor, but because of the move
semantics the deregistering is done for the wrong struct.

So in fact the only solution is to forbid copying the struct at all,
which might be the better solution anyway.

Thanks a lot! This really helped. 

Best regards,

Robert





More information about the Digitalmars-d mailing list