Expected or Bug? struct range unmodified after foreach

Jesse Phillips jessekphillips+d at gmail.com
Mon Nov 7 18:10:52 PST 2011


On Mon, 07 Nov 2011 18:52:19 +0100, Timon Gehr wrote:

> Expected, s has value semantics.
> 
> for(S _s=s; !_s.empty(); _s.popFront()){
>      auto i = _s.front();
>      // assert(i == s.popCount()); // expected to fail.
> }

Yes thank you. I was just hoping to have access to _s inside the loop.

And yeah, it likely would break lots of code. Granted I kind of wish all 
ranges would be consumed unless specifying save().


More information about the Digitalmars-d-learn mailing list