March 26, 2013 [Issue 9819] New: Allow access to named tuple's names. | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=9819 Summary: Allow access to named tuple's names. Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: enhancement Priority: P2 Component: Phobos AssignedTo: nobody@puremagic.com ReportedBy: jcrapuchettes@gmail.com --- Comment #0 from Jonathan Crapuchettes <jcrapuchettes@gmail.com> 2013-03-26 09:40:25 PDT --- Currently, the only way to access the field names inside a named tuple is to access the fieldSpecs alias, index a specific field, and then .stringof it. Example: --- auto t = Tuple!(int, "s", int, "d")(0, 1); enum e = t.fieldSpecs[0].stringof; pragma(msg, e); --- Prints: FieldSpec!(int, "s") I propose that the template FieldSpec be moved from the private section of the Tuple struct to the public section. This would allow for the field names to be accessed directly through the FieldSpec template. Example: --- auto t = Tuple!(int, "s", int, "d")(0, 1); enum e = t.fieldSpecs[0].name; pragma(msg, e); --- Prints: s -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation