[Issue 2411] New: Reference Tuple Foreach

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Oct 9 13:06:45 PDT 2008


http://d.puremagic.com/issues/show_bug.cgi?id=2411

           Summary: Reference Tuple Foreach
           Product: D
           Version: 2.019
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: dsimcha at yahoo.com


Sometimes, when iterating over a tuple representation of a class or struct, I
want to modify the class/struct contents.  Ex:

struct S {
    uint foo = 1;
}

void main() {
    S s;
    foreach(element; s.tupleof)
        element = 2;
    writeln(s.foo); //Still prints 1
}

It would be nice if I could do something like:

foreach(ref element; s.tupleof)

and this would modify s.foo.


-- 



More information about the Digitalmars-d-bugs mailing list