string gen_tuple(A...)(A a) {
string new_tuple = "alias " ~ a[0] ~ " = Tuple!(typeof(" ~ a[1] ~ ")";
foreach(entry; a[2 .. $])
new_tuple = new_tuple ~ ", typeof(" ~ entry ~ ")";
new_tuple = new_tuple ~ ");";
struct Record { int a; int b; string c; bool d; }
Record rec1; Record rec2;
rec1.a = 1; rec1.b = 2; rec1.c = "abc"; rec1.d = false;
rec2.a = 3; rec2.b = 4; rec2.c = "def"; rec2.d = true;
auto sum1 = tuple(rec1.a, rec1.b, rec1.d);
auto sum11 = tuple(1, 3, true);
auto sum2 = tuple(rec2.b, rec2.c, rec2.a);
auto sum22 = tuple(4, "ljl", 4);
mixin(gen_tuple("type1", "rec1.a", "rec1.b", "rec1.d"));
mixin(gen_tuple("type2", "rec2.b", "rec2.c", "rec2.a"));
RedBlackTree!type1 type1_recs;
RedBlackTree!type2 type2_recs;
type1_recs = make!(RedBlackTree!type1)(sum1);
type1_recs.insert(sum11);
type2_recs = make!(RedBlackTree!type2)(sum2);
type2_recs.insert(sum22);
Object[string] test_array;
test_array["port"] = type1_recs;
test_array["ip"] = type2_recs;
writeln((cast(typeof(type1_recs)) test_array["port"]).front);
writeln((cast(typeof(type2_recs)) test_array["ip"]).front);