Feature request - simpler constructors
Craig Black
cblack at ara.com
Fri Sep 21 13:37:53 PDT 2007
"Jarrett Billingsley" <kb3ctd2 at yahoo.com> wrote in message
news:fcurrh$ofa$1 at digitalmars.com...
> "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.
I agree. That is VERY cool.
More information about the Digitalmars-d
mailing list