ETOperatorSpec

式テンプレートでの演算子の種類を返します

template ETOperatorSpec (
A
string op
B
) if (
isValidOperator!(A, op, B)
) {
enum ETOSpec ETOperatorSpec;
enum ETOSpec ETOperatorSpec;
enum ETOSpec ETOperatorSpec;
}

Examples

1 static struct S(T, size_t r, size_t c)
2 {
3     enum rows = r;
4     enum cols = c;
5     T opIndex(size_t i, size_t j) const {return T.init;}
6     alias at = opIndex;
7 }
8 alias Matrix2i = S!(int, 2, 2);
9 
10 static assert(ETOperatorSpec!(Matrix2i, "+", Matrix2i) == ETOSpec.matrixAddMatrix);
11 static assert(ETOperatorSpec!(Matrix2i, "-", Matrix2i) == ETOSpec.matrixSubMatrix);
12 static assert(ETOperatorSpec!(Matrix2i, "*", Matrix2i) == ETOSpec.matrixMulMatrix);
13 static assert(ETOperatorSpec!(Matrix2i, "*", int) == ETOSpec.matrixMulScalar);
14 static assert(ETOperatorSpec!(int, "*", Matrix2i) == ETOSpec.scalarMulMatrix);

Meta