-
-
Save yshui/1db8bfd53962bb05fe66cfcfe0cae0b9 to your computer and use it in GitHub Desktop.
opDispatch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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