Skip to content

Instantly share code, notes, and snippets.

@pontifechs
Created April 22, 2014 07:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pontifechs/11169069 to your computer and use it in GitHub Desktop.
Save pontifechs/11169069 to your computer and use it in GitHub Desktop.
module tinker;
import std.stdio;
class A
{
int foo;
float bar;
}
class B
{
int baz;
float qux;
}
class DynamicTuple(T...)
{
T tuple;
string[] names;
this()
{
auto names = ["one", "two", "three"];
foreach (int i, name; names)
{
this.names ~= name;
}
}
auto notopDispatch(string s)() @property
{
foreach (i, elem; tuple)
{
if (names[i] == s)
{
return elem;
}
}
assert(false);
}
}
void main()
{
auto s = new DynamicTuple!(A,B)();
s.notopDispatch!("one")();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment