various questions
Jason Spencer
spencer8 at sbcglobal.net
Wed Jul 28 19:04:23 PDT 2010
That's COOL!
I'll have to look at these closer, but I definitely get what you're
doing. Thanks a million.
== Quote from bearophile (bearophileHUGS at lycos.com)'s article
> Simpler:
> import std.stdio: writeln;
> import std.typetuple: TypeTuple;
> template Iota(int stop) {
> static if (stop <= 0)
> alias TypeTuple!() Iota;
> else
> alias TypeTuple!(Iota!(stop-1), stop-1) Iota;
> }
> void foo(T, int N, int M)() {
> writeln(typeid(T), " ", N, " ", M);
> }
> enum string[] types = ["int", "float", "short"];
> alias TypeTuple!(int, float, short) types2;
> enum string[] sizes = ["100", "200", "250"];
> enum int[] sizes2 = [100, 200, 250];
> void main() {
> string run_t = "int";
> string run_n = "200";
> string run_m = "100";
> foreach (t; Iota!(types.length))
> foreach (n; Iota!(sizes.length))
> foreach (m; Iota!(sizes.length))
> if (run_t == types[t] && run_n == sizes[n] && run_m
== sizes[m]) {
> foo!(types2[t], sizes2[n], sizes2[m])();
> goto END;
> }
> END: {}
> }
More information about the Digitalmars-d-learn
mailing list