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: [email protected]
          Reporter: [email protected]

>From http://beta.forum.dlang.org/post/[email protected]

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

--

Reply via email to