Ok, so I'm having a struct that has a constructor that takes a template parameter. I suppose this question could also be named how to initialize constructors with template parameters
but whatever! The funny thing is, I think that I may have already found how to do it in the past but I forgot... This time, I'm going to add the code in a big module in my project so I'm not going to have it as a reference and I won't forget it.
Here is a small sample code:
import std.stdio;
struct Test {
this(string type = "def")(string reg_arg) {
writeln("reg_arg: ", reg_arg);
}
}
void main() {
auto test = Test.__ctor!("non_def")("Hello");
}
And the error I get: test.d(10): Error: need
thisfor
thisof type
ref @safe Test(string reg_arg)`