Confusion regarding struct lifecycle

maik klein via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Feb 15 19:31:51 PST 2016


On Tuesday, 16 February 2016 at 02:09:15 UTC, Matt Elkins wrote:
> I've been bitten again by my lack of understanding of the D 
> struct lifecycle :-/. I managed to reduce my buggy program to 
> the following example:
>
> [...]

In D you can always call Foo.init even with @disable this(), The 
first 3 destructor calls are from the 3 Foo.inits in your static 
array. I guess because you disabled the copy constructor, the 
Foo's will be moved and then they also need to call the 
destructor of the Foo.inits. Just like std::move does.


More information about the Digitalmars-d-learn mailing list