Re: Scoped in a foreach loop.

2015-06-05 Thread via Digitalmars-d
On Friday, 5 June 2015 at 09:06:56 UTC, Marc Schütz wrote: On Friday, 5 June 2015 at 03:07:53 UTC, Yuxuan Shui wrote: I tried something like this: foreach(e; scoped!SomeRangeType(args)) { } And my program segment faults. But this works: { auto x = scoped!SomeRangeType(args); foreach(e;

Re: Scoped in a foreach loop.

2015-06-05 Thread Lionello Lunesu via Digitalmars-d
On 05/06/15 05:07, Yuxuan Shui wrote: I tried something like this: foreach(e; scoped!SomeRangeType(args)) { } And my program segment faults. But this works: { auto x = scoped!SomeRangeType(args); foreach(e; x) { } } Shouldn't the range be alive until the end of the loop?

Re: Scoped in a foreach loop.

2015-06-05 Thread via Digitalmars-d
On Friday, 5 June 2015 at 03:07:53 UTC, Yuxuan Shui wrote: I tried something like this: foreach(e; scoped!SomeRangeType(args)) { } And my program segment faults. But this works: { auto x = scoped!SomeRangeType(args); foreach(e; x) { } } Shouldn't the range be alive until the end