struct Test
{
int n;
float f;
static Test opCall(int n, float f)
{
return Test(n, f);
}
}
void main()
{
Test(1, 2.0);
}
This code causes an infinite loop because the Test(n, f)
inside the static opCall
is interpreted as a recursive call to that same opCall
function - not a call to the struct's constructor (or however this is interpreted by the compiler when there is no explicit struct/union constructor defined).
I tried doing return Test.__ctor(n, f)
but it says that symbol doesn't exist. Is there any way to explicitly call the struct's constructor so it doesn't cause an infinitely recursive call to opCall
?