www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2411] New: Reference Tuple Foreach

reply d-bugmail puremagic.com writes:
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 digitalmars.com
        ReportedBy: dsimcha 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.


-- 
Oct 09 2008
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2411


David Simcha <dsimcha yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |sean invisibleduck.org




--- Comment #1 from David Simcha <dsimcha yahoo.com>  2009-06-02 05:51:21 PDT
---
*** Issue 3045 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 02 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2411


bearophile_hugs eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs eml.cc


--- Comment #2 from bearophile_hugs eml.cc 2010-03-07 10:28:09 PST ---
Bug 3835 is a partial duplicate of this (one case seems different).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 07 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2411


Trass3r <mrmocool gmx.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mrmocool gmx.de


--- Comment #3 from Trass3r <mrmocool gmx.de> 2010-05-20 15:12:01 PDT ---
This is a workaround:

foreach (i, dummy ; s.tupleof)
        s.tupleof[i] = 2;

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 20 2010