[Issue 14653] New: scoped range in foreach

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Jun 5 02:05:42 PDT 2015


https://issues.dlang.org/show_bug.cgi?id=14653

          Issue ID: 14653
           Summary: scoped range in foreach
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Mac OS X
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: DMD
          Assignee: nobody at puremagic.com
          Reporter: lio+bugzilla at lunesu.com

>From http://beta.forum.dlang.org/post/srjjrjrpjgdnlhsqlyca@forum.dlang.org

class SomeRangeType
{
  int a;
  this(T)(T...) { }
  ~this() { a = -1; }
  @property int front() { assert(a>=0); return a; }
  void popFront() { ++a; }
  @property bool empty() { return a < 10; }
}
void main(string[] args)
{
  import std.typecons;
  foreach(e; scoped!SomeRangeType(args)) {}
}


$ dmd -g -debug -run ~/testforeach.d
--- killed by signal 11

--


More information about the Digitalmars-d-bugs mailing list