On Monday, 20 May 2013 at 15:15:33 UTC, John Colvin wrote:
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.

This would also leads to bugs when invalid code is silently accepted in each user-defined type where opDispatch is defined.

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.

And this is pushing UFCS beyond its purpose for the sake of temporal convenience at the expense of language.

Reply via email to