how do I get the ith field of a std.typecons.Tuple ?

John Colvin john.loughran.colvin at gmail.com
Sun Aug 18 02:15:18 PDT 2013


On Sunday, 18 August 2013 at 08:46:17 UTC, Timothee Cour wrote:
> A)
> how do I get the ith field of a std.typecons.Tuple ?
> ideally, it should be as simple as:
>
> auto t=Tuple!(int,"name",double,"name2")(1);
> static assert(t.fields[0] == "name");

field is the old name for expand, retained for compatibility, 
it's not recommended. It gives you direct access to the tuple 
inside the Tuple struct, but it's for getting the variable 
values, not their names.

If you want to get the *names* you've chosen for the tuple 
fields, you'll have to use traits of some sort I think.


More information about the Digitalmars-d-learn mailing list