www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4381] New: Length attribute for std.typecons.Tuple

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4381

           Summary: Length attribute for std.typecons.Tuple
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc


--- Comment #0 from bearophile_hugs eml.cc 2010-06-24 04:01:13 PDT ---
This little program (that doesn't work with DMD v2.047) shows why a (constant)
length attribute can be quite useful for tuples:


import std.typecons: Tuple;
import std.typetuple: TypeTuple;
template Iota(int start, int stop) { // 2 argument version
    static if (stop <= start)
        alias TypeTuple!() Iota;
    else
        alias TypeTuple!(Iota!(start, stop-1), stop-1) Iota;
}
void main() {
    alias Tuple!(char, int, int) Unit;
    auto u1 = Unit('x', 1, 2);
    auto u2 = Unit('y', 10, 20);
    foreach (i; Iota!(1, Unit.length))
        u1.field[i] += u2.field[i];
}


In that program u1.length (and maybe Unit.length too) needs to be 3.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 24 2010
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4381


David Simcha <dsimcha yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |dsimcha yahoo.com
         Resolution|                            |FIXED


--- Comment #1 from David Simcha <dsimcha yahoo.com> 2010-08-14 19:01:55 PDT ---
Fixed SVN.

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