Merge 2 structs together (into a single struct)?

Ali Çehreli acehreli at yahoo.com
Thu Sep 16 20:48:47 UTC 2021


On 9/16/21 1:12 PM, james.p.leblanc wrote:

 > I really thought that this would be a simple enough
 > small project in meta programming/reflection.

It should be doable. One question is how to resolve conflicting members 
of the two structs, which can be defaulted to one of the policies "cause 
compilation error", "do name mangle", "ignore second", etc.

 > .... the point of this is really to use the struct AB
 > for getopt reading of command line options.

I pass local variables to getopt and then construct a struct from them:

   int a;
   double d;

   getopt(/* ... */, &a, /* ... */, &d);

   myFunction(MyStruct(a, d));

Do you want to pass members of a struct to getopt?

   auto m = MyStruct();

   getopt(/* ... */, &m.a, /* ... */, &m.d);

Ali



More information about the Digitalmars-d-learn mailing list