On Friday, 25 July 2014 at 15:48:54 UTC, John Colvin wrote:
On Friday, 25 July 2014 at 15:25:43 UTC, BlackEdder wrote:
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]
On Friday, 25 July 2014 at 15:25:43 UTC, BlackEdder wrote:
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
BlackEdder:
Is this possible at all?
I think it's possible, as long as your associative array contents
are known at compile-time. You can write a function that given
the associative array returns a string that mixed-in defines the
struct. And then you can define a toStruct template.
Bye,