struct Field { TypeInfo Type; uint Offset; } Field[] Fields(C)(C c) { Field[] fields = new Field[0]; foreach(i, a; typeof(C.tupleof)) { Field m; static if(i == 0) { static if(is(C == class)) { m.Offset = 8; } else { m.Offset = 0; } } else { Field n = fields[i-1]; m.Offset = n.Offset + n.Type.sizeof; } m.Type = typeid(typeof(a)); fields.length = fields.length + 1; fields[i] = m; } return fields; } struct MyStruct1 { int afield; void* apointer; } struct MyStruct2 { real afield; ubyte[] apointer; } void main() { MyStruct1 s1; Field[] fs1 = Fields(s1); assert(fs1[0].Type == typeid(int)); assert(fs1[1].Type == typeid(void*)); MyStruct2 s2; Field[] fs2 = Fields(s2); assert(fs2[0].Type == typeid(real)); // fails here assert(fs2[1].Type == typeid(ubyte[])); }