xxxxxxxxxx
mixin template FinalCtor()
{
this(typeof(this.tupleof) args)
{
this.tupleof[] = args[];
}
static foreach (i; 1 .. this.tupleof.length)
this(typeof(this.tupleof)[0 .. i] args)
{
this.tupleof[0 .. i] = args[];
}
}
struct S
{
int x;
double y;
string z;
mixin FinalCtor;
}
void main()
{
static assert( __traits(compiles, S()));
static assert(!__traits(compiles, S(1)));
static assert(!__traits(compiles, S(1, 2.0)));
static assert( __traits(compiles, S(1, 2.0, "three")));
S s = S(1, 2.0, "three"); // feel free to remove arguments and see the error messages.
}