Assigning to array of structs with custom constructor

Ali Çehreli acehreli at yahoo.com
Tue Apr 26 05:02:01 UTC 2022


On 4/25/22 21:32, Salih Dincer wrote:

 > So the problem is that the structure is not in the inter-module space

Nested structs carry an additional pointer to their containing context. 
When they don't need the context, we define them with 'static':

void foo() {
   static struct Bar { }
}

 > If ```sruct Foo {}``` is not taken outside of ```main()``` it will fail
 > for many possibilities!

Only if the struct needs the context. Otherwise, nested structs should 
be defined with 'static' and there is no issue with map...

Ali



More information about the Digitalmars-d-learn mailing list