www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9819] New: Allow access to named tuple's names.


           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.

auto t = Tuple!(int, "s", int, "d")(0, 1);
enum e = t.fieldSpecs[0].stringof;
pragma(msg, e);
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.

auto t = Tuple!(int, "s", int, "d")(0, 1);
enum e = t.fieldSpecs[0].name;
pragma(msg, e);

Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 26 2013