auto opBinary(string op, M:Matrix!O, O)(M other) {
alias P = typeof(T.init * O.init);//編譯器計算類型
//p=提升
//,在實際改變每操作傳回值時更靈活
static if(op == "*") {//編譯時參數,用.靜如
Matrix!P result;//傳回類型
if(columns == other.rows) {
result = new Matrix!P(rows, other.columns);
} else {
result = new Matrix!P(0,0);
}
return result;
} else static assert(0,"未實作"~op~"操作符");
//靜如,可以靜斷定
}
}//索引指派,這裡完全是插入串
mixin(define_opbinary(int.stringof));
mixin(define_opbinary(uint.stringof));
//不能下面這樣
mixin define_opbinary!(int);
mixin define_opbinary!(uint);
//這裡不一樣