alias parameter tuples:  need this to access member
    Tobias Pankrath 
    tobias at pankrath.net
       
    Sat May 26 03:39:29 PDT 2012
    
    
  
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 :)
    
    
More information about the Digitalmars-d-learn
mailing list