"in" operator gives a pointer result from a test against an Associative Array?

Andy Valencia dont at spam.me
Fri May 10 00:18:16 UTC 2024


tst7.d(6): Error: cannot implicitly convert expression `e in 
this.members` of type `bool*` to `bool`
tst7.d(15): Error: template instance `tst7.Foo!uint` error 
instantiating

I'm getting this for this bit of source (trimmed from the bigger 
code).  I switched to this.members.get(e, false) and that works 
fine, but I'm still curious:

struct Foo(T) {
     bool[T] members;

     bool
     has(T e) {
         return (e in this.members);
     }
}

void
main()
{
     import std.stdio : writeln;

     auto t = Foo!uint();
     writeln(t.has(123));
}


More information about the Digitalmars-d-learn mailing list