On 10/25/22 08:50, Andrey Zherikov wrote:
> I'd like to tune default ctor but structs can't have custom one.
> Adding a ctor with parameter seems a hack to me
There is static opCall, which may be seen as a hack as well. :) The
following all print the same thing now:
import std.stdio;
struct A
{
int[] i;
}
struct B
{
A[] a = [A.init];
static B opCall()
{
return B.init;
}
}
void main()
{
auto b1 = B.init;
b1.writeln;
B b2 = B();
b2.writeln;
B b3;
b3.writeln;
}
> This fails in run time
Not anymore with the above code.
Ali