Error: constructor Foo.this default constructor for structs only allowed with @disable, no body, and no parameters

Alex Parrill via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Mar 7 06:54:49 PST 2016


On Monday, 7 March 2016 at 13:23:58 UTC, Nicholas Wilson wrote:
> I'm not quite sure what this error is saying. Is it that the 
> only struct constructor that can have no parameters is @disable 
> this(){} ?

Yes, this is exactly right. You cannot have a structure with a 
default constructor, except with @disable.

You can, however, specify the initial values of fields, as in 
your second example. Note that you can use typeof on the variable 
you are currently declaring.

VkFenceCreateInfo CI = 
typeof(CI)(cast(typeof(CI.sType))StructureType.eFenceCreateInfo, 
null, 0);



More information about the Digitalmars-d-learn mailing list