alias this and associative arrays

Shachar Shemesh shachar at weka.io
Sun Apr 22 11:06:12 UTC 2018


import std.exception;

struct AA(Key, Val) {
     Val[Key] aa;
     alias aa this;

     void opIndexAssign(inout Val value, Key key) pure {
         aa[key] = value;
     }
}

void main() {
     AA!(string, int) a;
      //compile error -- no property 'remove' for type 
'CheckedAA!(string, int)'
     a.remove("aaa");
}

What's wrong here?


More information about the Digitalmars-d mailing list