I am writing a mixin template that uses alias parameters and should me instantiated in a class. With only one parameter, it works. But I fail with
using multiple aliases as a tuple.

This works:

mixin template print(alias x) {
    void doprint() { writeln(x); }
}

class A { int x; mixin print!x; }

Now I would like to do the same, but with several attributes of my class at once. Thus I tried tuple parameters:

mixin template print(alias b...) { ... } // seem not to be legal syntax.

My second try was this:

mixin template print(b...)
{
    void doprint() {
        foreach(mem; b)
            writeln(b);
    }
}

class A { int x,y; mixin print!(x, y); }

Now DMD says:  need this to access member

How can I do this? Thank you in advance :)

Reply via email to