opDispatch and operator overloads

John Colvin john.loughran.colvin at gmail.com
Mon May 20 08:15:32 PDT 2013


struct S {
	auto opDispatch(string s)(A i){}
}

struct A {}

void main() {
	S s;
	A a;
	s + a; //Error: incompatible types for ((s) + (a)): 'S' and 'A'
}

It would be really nice if opDispatch could catch missing 
operator overloads.

Also, would it be a good idea to have free functions of all the 
operators (opOpAssign etc...) for builtin types somewhere? It's 
occasionally useful in generic wrappers.


More information about the Digitalmars-d mailing list