On 10/16/16 3:58 PM, Andrei Alexandrescu wrote:
I was thinking it would be handy if tuples had a way to access a field
by name at runtime. E.g.:
Tuple!(int, "a", double, "b") t;
string x = condition ? "a" : "b";
double v = t.get!string(x, 3.14);
I swear I've seen a pull request merged that adds an accessible "names"
AliasSeq with names of fields. That should be a good starting point.
The get method takes the field name and the type of the presumed field,
and it returns the value of the field in the tuple. If no field by that
name and type, return the second argument.
* Do not throw - allow the second argument to be a throwing delegate
* Do not add overhead if the method is never used
* Figure out a reasonable (but not all too complicated) way to deal with
implicit conversions, e.g. if x == "a" in the the code above, should it
return 3.14 or convert the int to double?
* Handle qualifiers appropriately