On 8/7/22 22:38, rempas wrote:

> I want to create it and be able to successfully initialize the template
> parameters
> of the constructor but until now, I wasn't able to find a way to
> successfully do
> that.

The following method uses a convenience function but it's not really needed:

import std.stdio;

struct TestArray(ulong element_n, string type) {
  int[element_n] elements;
  mixin(type) member;
  pragma(msg, "The type is: ", typeof(member));

  this(ulong number) {
    writeln("Constructing with ", number);
  }
}

auto makeTestArray(ulong element_n, string type)(ulong number) {
  return TestArray!(element_n, type)(number);
}

void main() {
  auto ta = makeTestArray!(10, "int")(60);
}

Ali

Reply via email to