Skip to content

Instantly share code, notes, and snippets.

@crazymonkyyy
Created October 9, 2023 02:55
Show Gist options
  • Save crazymonkyyy/012c63e96aabed47fcb7787b0bc360a2 to your computer and use it in GitHub Desktop.
Save crazymonkyyy/012c63e96aabed47fcb7787b0bc360a2 to your computer and use it in GitHub Desktop.
import std;
struct opindexopdispatch{
int i=0;
auto opIndex(T...)(T args){
struct op{
opindexopdispatch* parent;
T args;
auto opDispatch(string op:"isnull",S...)(S args2){
//pragma(msg,op,T,S);
return (*parent).opopdispatch!(T,op)(args,args2);
}
}
return op(&this,args);
}
void opopdispatch(I,I2,string op,T...)(I i,I2 i2,T args){
//pragma(msg,op,T,"2d");
import std;
writeln(op,";",args,";",T.stringof);
}
void opopdispatch(I,string op:"isnull",T...)(I i,T args){
//pragma(msg,op,T,"1d");
import std;
writeln(op,";",args,";",T.stringof);
}
}
unittest{
opindexopdispatch foo;
foo[420,1337].isnull=true;
foo[420].isnull=true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment