[Issue 9819] New: Allow access to named tuple's names.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Mar 26 09:40:26 PDT 2013


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 at puremagic.com
        ReportedBy: jcrapuchettes at gmail.com


--- Comment #0 from Jonathan Crapuchettes <jcrapuchettes at 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: -------


More information about the Digitalmars-d-bugs mailing list