Confusion regarding struct lifecycle

Marc Schütz via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Feb 16 02:45:09 PST 2016


On Tuesday, 16 February 2016 at 04:00:27 UTC, Mike Parker wrote:
> On Tuesday, 16 February 2016 at 03:39:00 UTC, Matt Elkins wrote:
>> On Tuesday, 16 February 2016 at 03:31:51 UTC, maik klein wrote:
>>> In D you can always call Foo.init even with @disable this(),
>>
>> Foo.init can be called implicitly (not just explicitly)? If 
>> so, why even have @disable this(), if it offers no guarantees?
>
> IMO, this is a bug. It should have to be explicit, just as it 
> is with a single struct instance.

There is likely some bug here. In the example, though, the 
elements _are_ constructed explicitly (except foos[4]). This is 
legitimate, as the first assignment of an element in a construct 
counts as construction.


More information about the Digitalmars-d-learn mailing list