Feature request - simpler constructors
Jarrett Billingsley
kb3ctd2 at yahoo.com
Thu Sep 20 15:23:05 PDT 2007
"Craig Black" <cblack at ara.com> wrote in message
news:fcuggd$575$1 at digitalmars.com...
> Another idea:
>
> this(auto ...) {}
>
> Could do all the parameters. So even less typing.
>
template AutoCtor()
{
this(typeof(typeof(this).tupleof) args)
{
foreach(i, val; args)
this.tupleof[i] = val;
}
}
class A
{
int x, y, z;
float w;
mixin AutoCtor;
}
void main()
{
scope a = new A(4, 5, 6, 7.8);
Stdout.formatln("{} {} {} {}", a.x, a.y, a.z, a.w);
}
Templates are just.. too cool.
More information about the Digitalmars-d
mailing list