On 21.09.2016 22:53, HaraldZealot wrote:
On Wednesday, 21 September 2016 at 19:01:40 UTC, Timon Gehr wrote:


Basically, the rationale is: external operators cannot be used in
generic code that does not import the module defining the operators.

Could you give some elaborate example, for now I can't imagine what your
mean.

module a;

struct Foo{}

Foo opBinary(string op:"+")(Foo a, Foo b){ return Foo(); }

---

module b;

T add(T)(T a,T b){
    return a + b;
}

---

module c;
import a,b;

void main(){
    Foo x=add(Foo(),Foo()); // error
}

Reply via email to