On Saturday, 20 July 2013 at 16:46:52 UTC, JS wrote:
class MyClass {
auto opBinary(string op : "|" T : int)(T t) { }
// opBinary is completely specialized and is no
different than a regular function, it can be overridden
directly in children without having to use a redirection. (note
in your opBinaryImpl, T must be specified
}
I understand there is a little boilerplate when wanting to have
overriding for the operator overloads, but I don't see much gain
from the proposal.
Do you really want to force people to write
int opBinary(string op : "|" T : int)(T t)
instead of
override int opOr(int t)
when trying to override your function?
Though it might be interesting if an aliased function could be
overridden:
class I {
final int opBinary(string op)(int t) { ... }
alias opAdd = opBinary!"+";
}
class MyClass : I{
override int opAdd(int v) { ... }
}