Here is another one that uses nested templates:

import std.stdio;

template TestArray(ulong element_n) {
  struct TestArrayImpl(Type) {
    int[element_n] elements;

    this(ulong number) {
      pragma(msg, "The type is: ", Type);
      writeln("Constructing with ", number);
    }
  }

  auto makeFor(string s)(ulong number) {
    return TestArrayImpl!(mixin(s))(number);
  }
}

void main() {
  auto ta = TestArray!10.makeFor!"int"(60);
}

Ali

Reply via email to