import std.stdio, std.typecons; struct Container(ID, Properties...) { Tup!(ID, Properties)[] contents; void add(ID i, Properties p) { static if(Properties.length == 0) contents ~= Tup!(ID)(i); else contents ~= Tup!(ID, Properties)(i, p); } } template Tup(ID, Properties...) { static if(Properties.length == 0) alias Tuple!(ID, "id") Tup; else alias Tuple!(ID, "id", Properties) Tup; } void main() { writeln(); auto c1 = Container!(size_t)(); c1.add(3); c1.add(7); c1.add(2); writeln(c1); foreach(t, tup; c1.contents) writeln("[", t, "] ", tup.id); writeln(); auto c2 = Container!(size_t, real, real)(); c2.add(5, 3.2, 5.6); writeln(c2); writeln(); auto t1 = Tup!(size_t, real, "value")(3, 4.5); writeln(t1); writeln(t1.id, " ", t1.value); auto t2 = Tup!(size_t, real, "value", bool, "active")(3, 4.5, true); writeln(t2); writeln(t2.id, " ", t2.value, " ", t2.active); auto c3 = Container!(size_t, real, "value")(); // this falls over }