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: nob...@puremagic.com ReportedBy: bearophile_h...@eml.cc --- Comment #0 from bearophile_h...@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: -------