On 08/01/13 14:50, John Colvin wrote: > template a(T ...) > { > void a(R r) > { > //want to get a tuple of > //the members of T, each > //instantiated with R. > > //do some RT stuff > } > } > > Is this possible? > > Whatever I try, I keep running in to "cannot use local as parameter to > non-global template" errors, which I understand is to do with context pointers > However, this is all compile-time work based entirely on types, there should > be no need for any context pointers. >
Always post real and complete (even if not working) code, as figuring out what the problem is can be harder than giving the solution... template RealTuple(A...) { alias RealTuple = A; } template a(T ...) { auto a(R)(R r) { //want to get a tuple of //the members of T, each //instantiated with R. mixin({ string m; foreach (I, _; T) m ~= "alias UGH"~I.stringof~" = T["~I.stringof~"];\n"; m ~= "alias TupleofTsBangR = RealTuple!("; foreach (I, _; T) m ~= (I?", ":"") ~ "UGH"~I.stringof~"!R"; return m ~ ");"; }()); // do some RT stuff TupleofTsBangR x; foreach (I, _; typeof(x)) x[I] = r; // etc import std.typecons; return tuple(x); } } (If this is what you were actually looking for then I hope somebody else has another solution; this approach is just too ugly...) artur