What's wrong in this templatized operator overload ?

MobPassenger via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Oct 21 20:19:47 PDT 2015


code:
---
struct Foo
{
     bool opIn_r(T)(T t){return false;}
}

static immutable Foo foo; // ouch
//static Foo foo; // OK

void main()
{
     assert("a" !in foo);
}
---

output:
---
Error: template Foo.opIn_r cannot deduce function from argument 
types !()(string) immutable, candidates are:
runnable.Foo.opIn_r(T)(T t)
---


More information about the Digitalmars-d-learn mailing list