OpIndex/OpIndexAssign strange order of execution
    Ali Çehreli 
    acehreli at yahoo.com
       
    Mon Sep 18 16:37:42 UTC 2017
    
    
  
Have you considered the multiple indexes?
   https://dlang.org/spec/operatoroverloading.html#index_assignment_operator
It may give you some power in execution order.
import std.stdio;
struct S {
     auto opIndex(string index) {
         writeln(index);
         return 42;
     }
     auto opIndexAssign(int value, string[] indexes...) {
         writeln(indexes);
     }
}
void main() {
     auto s = S();
     s["b", "c"] = s["a"];
}
Prints
a
["b", "c"]
Ali
    
    
More information about the Digitalmars-d-learn
mailing list