Re: What's wrong in this templatized operator overload ?

2015-10-22 Thread MobPassenger via Digitalmars-d-learn
On Thursday, 22 October 2015 at 05:17:29 UTC, Cauterite wrote: On Thursday, 22 October 2015 at 04:25:01 UTC, MobPassenger wrote: On Thursday, 22 October 2015 at 04:01:16 UTC, Mike Parker wrote: On Thursday, 22 October 2015 at 03:19:49 UTC, MobPassenger wrote: code: --- struct Foo { bool op

Re: What's wrong in this templatized operator overload ?

2015-10-21 Thread MobPassenger via Digitalmars-d-learn
On Thursday, 22 October 2015 at 04:01:16 UTC, Mike Parker wrote: On Thursday, 22 October 2015 at 03:19:49 UTC, MobPassenger wrote: code: --- struct Foo { bool opIn_r(T)(T t){return false;} } This needs to be marked with const: struct Foo { bool opIn_r(T)(T t) const {return false;} }

Re: What's wrong in this templatized operator overload ?

2015-10-21 Thread MobPassenger via Digitalmars-d-learn
On Thursday, 22 October 2015 at 03:18:25 UTC, MobPassenger wrote: code: Plz don't reply, there's been a forum bug while posting. Full post is here: http://forum.dlang.org/thread/kaqyeiakjunqoexos...@forum.dlang.org

What's wrong in this templatized operator overload ?

2015-10-21 Thread MobPassenger via Digitalmars-d-learn
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); }

What's wrong in this templatized operator overload ?

2015-10-21 Thread MobPassenger via Digitalmars-d-learn
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: runna