Associative array to Struct at compile time

BlackEdder via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Jul 25 08:25:43 PDT 2014


Is it possible to automatically convert an associative array to a
struct?

Basically I want to do the following (for any struct).

struct A {
     double x = 1;
}

double[string] aa = ["x":1];

auto a = toStruct!A( aa );

I've been trying to do this at compile time, but can't work out
how setMembers and or loop over the associative array at compile
time.

Is this possible at all?


More information about the Digitalmars-d-learn mailing list