On 5/17/12, bearophile <bearophileh...@lycos.com> wrote:
> snip

Mixin workaround:

import std.conv;

@property string makeCtors(T)()
{
    T t;
    string res;
    foreach (i; 0 .. typeof(t.tupleof).length)
    {
        res ~= "this(typeof(this.tupleof[0.."
                ~ to!string(i+1)
                ~ "]) tup) { this.tupleof[0.."
                ~ to!string(i+1) ~ "] = tup; }\n";
    }

    return res;
}

struct Node
{
    mixin(makeCtors!Node);
    int data;
    Node* next;
}

void main() {
    Node* n1 = new Node(10); // OK
    Node* n2 = new Node(10, null); // OK
}

Reply via email to