I want to use mixin to generate function in-place. In template declaration, I can see 'mixin' keyword is optional. Is it true? What is the difference and when I must use one way over another?

This is my program:

// This works with and without 'mixin' attribute.
mixin template funcgen(T, U){

  T func1(string pr2){
    writeln("Func1: ", pr2);
  }
  U func2(string pr3){
    writeln("Func2: ", pr3);
  }

}

int main(string[] args){

  mixin funcgen!(void, void);
  func1("func1");
  func2("func2");
  return 0;

}

Reply via email to