Hello,
I'm trying to create a mixin for quick binary operator overloads by passing in types with a corresponding associative array of strings to functions. However,
the code I currently have:
module foo;
mixin template opBi(
A, A function(A, A)[string] f0,
) {
static foreach (k, f; f0) { A opBinary(string op: k)(A r) { return f(this, r); } }
}
struct A {
mixin opBi!(
A, [ "+": (A a, A b) => a],
);
}
struct B {
mixin opBi!(
B, [ "+": (B a, B b) => a],
);
}
Will not let me override operators on both struct A and B.
I get:
foo.d(16): Error: mixin `foo.B.opBi!(B, ["+":function (B a, B b) pure nothrow @nogc @safe => a])` does not match template declaration `opBi(A, A function(A, A)[string] f0)`
Is this a bug or am I doing something wrong?