Post-ctor ctor

Andrej Mitrovic andrej.mitrovich at gmail.com
Mon Aug 8 15:43:59 PDT 2011


On 8/8/11, KennyTM~ <kennytm at gmail.com> wrote:
> Template-mixin is often shorter and less error-prone.
> -----------------
>
> mixin template FieldInit(size_t count, alias fun)
> {
>      this(RepresentationTypeTuple!(typeof(this))[0..count] params)
>      {
>          foreach (y, x; __traits(allMembers, typeof(this))[0..count])
>              __traits(getMember, this, x) = params[y];
>          fun();
>      }
> }
>

Yum! That's much sexier, thanks.


More information about the Digitalmars-d mailing list