I bam close to be done import std.stdio; import std.typecons; import std.conv;
struct Coord { int x; int y; int z; } template toTuple(T){ static string maker(){ string statement = "alias Tuple!("; foreach(const memberName; __traits(allMembers, T)){ statement ~= typeof(__traits(getMember, T, memberName)).stringof ~ ",\"" ~ memberName ~ "\", " ; } statement = statement[0..$-2] ~ ") toTuple;" ; // $-1 to remove extra comma return statement; } pragma( msg, maker() ); mixin( maker() ); } void main() { //auto a = c.tupleof; auto a = toTuple!Coord; } $ ldc2 -w -of"testTupleof" "testTupleof.d" alias Tuple!(int,"x", int,"y", int,"z") toTuple; testTupleof.d(29): Error: type Tuple!(int, "x", int, "y", int, "z") has no value