Hello,

I took some code snippet from some sample D code and modified it a bit:

template TCopy(T, V) {
  private int i = 2;
        
  void copy(out T to, out V to2, T from) {
    to = from;
    to2 = from;
    writeln("i: ", i);
  }
}

void main(string[] args)
{
        int x = 2;
        int y = 2;
        alias myCopy = TCopy!(int, int);        
        myCopy.copy(x, y, 37);
        writeln("x: ", x, " y: ", y);
}

My question is now why I have to declare and alias as in

alias myCopy = TCopy!(int, int);

If I define auto instead of alias, it does not compile. My question is why defining auto does not work. I would consider this more intuitive.

Thanks, Bienlein

Reply via email to