Skip to content

Instantly share code, notes, and snippets.

@yshui
Created January 26, 2017 22:30
Show Gist options
  • Save yshui/1db8bfd53962bb05fe66cfcfe0cae0b9 to your computer and use it in GitHub Desktop.
Save yshui/1db8bfd53962bb05fe66cfcfe0cae0b9 to your computer and use it in GitHub Desktop.
opDispatch
struct R(T...) {
T data;
auto opDispatch(string str)() {
import std.conv;
return data[to!int(str[1..$])];
}
}
int main() {
import std.stdio;
auto tmp = R!(int, float)(1,2.0);
writeln(tmp.x1);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment